File: with_postgresql.yaml

package info (click to toggle)
python-ara 1.5.8-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,460 kB
  • sloc: python: 6,493; sh: 215; makefile: 15; javascript: 2
file content (93 lines) | stat: -rw-r--r-- 3,105 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#  Copyright (c) 2019 Red Hat, Inc.
#
#  This file is part of ARA Records Ansible.
#
#  ARA is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ARA is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with ARA.  If not, see <http://www.gnu.org/licenses/>.

- name: Start a postgresql container
  hosts: ara-database-server
  gather_facts: yes
  vars_files:
    - vars/postgresql_tests.yaml
  tasks:
    - name: Install podman
      become: yes
      package:
        name: podman
        state: present

    - name: Start a postgresql container
      command: |
        podman run -d \
          --name {{ _postgresql_container_name }} \
          -p {{ ara_api_database_port }}:{{ ara_api_database_port }} \
          -e POSTGRES_DB={{ ara_api_database_name }} \
          -e POSTGRES_USER={{ ara_api_database_user }} \
          -e POSTGRES_PASSWORD={{ ara_api_database_password }} \
          {{ _postgresql_image_name }}
      register: db_container
      retries: 3
      delay: 5
      until: db_container is succeeded

    # podman doesn't appear to be able to listen on ipv6 yet: https://github.com/containers/libpod/issues/3245
    # If we have a node on IPv6, redirect the traffic from v6 to v4 with socat
    - when: ansible_host | ipv6 != false
      become: yes
      block:
        - name: Install socat
          package:
            name: socat
            state: present

        - name: Setup systemd service
          copy:
            dest: /etc/systemd/system/socat-postgresql.service
            owner: root
            group: root
            mode: 0644
            content: |
              [Unit]
              Description=socat postgresql ipv6 to ipv4
              [Service]
              ExecStart=/usr/bin/socat TCP6-LISTEN:5432,fork,bind=[{{ ansible_host }}] TCP4:127.0.0.1:5432

              [Install]
              WantedBy=multi-user.target

        - name: Start socat network redirection for postgresql over ipv6
          service:
            name: socat-postgresql
            state: started
            enabled: yes
            daemon_reload: yes

- name: Deploy and test ARA API with postgresql
  hosts: ara-api-server
  gather_facts: yes
  vars_files:
    - vars/postgresql_tests.yaml
  tasks:
    - name: Set database server host
      set_fact:
        ara_api_database_host: "{{ hostvars['database-server']['ansible_host'] }}"

    - name: Set up the API with the ara_api Ansible role
      include_role:
        name: ara_api
        public: yes

    # These are tasks rather than a standalone playbook to give us an easy
    # access to all the variables within the same play.
    - include_tasks: test_tasks.yaml