90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
# 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 }}
|
|
|
|
# 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
|