diff --git a/README.md b/README.md index 0450817..8d57106 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ open_asfa_docker_service_client_name: 'asfa-client-test' open_asfa_docker_server_image: 'lucabrl01/asfa-server' open_asfa_docker_client_image: 'lucabrl01/asfa-client' open_asfa_docker_network: 'open_asfa_test_net' -# IMPORTANT. Set it to True for the server that is going to host the DB -open_asfa_docker_db_node: True open_asfa_behind_haproxy: True open_asfa_haproxy_public_net: 'haproxy-public' # DB diff --git a/defaults/main.yml b/defaults/main.yml index 3f6c0b8..160e6a8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,14 +6,13 @@ open_asfa_docker_service_client_name: 'asfa-client-test' open_asfa_docker_server_image: 'lucabrl01/asfa-server' open_asfa_docker_client_image: 'lucabrl01/asfa-client' open_asfa_docker_network: 'open_asfa_test_net' -# IMPORTANT. Set it to True for the server that is going to host the DB -open_asfa_docker_db_node: True open_asfa_behind_haproxy: True open_asfa_haproxy_public_net: 'haproxy-public' # DB open_asfa_db_as_container: True open_asfa_db_pg_version: 12 open_asfa_db_image: 'postgres:{{ open_asfa_db_pg_version }}-alpine' +open_asfa_db_docker_host: 'localhost' open_asfa_db_host: 'pg' open_asfa_db_port: 5432 #open_asfa_db_pwd: 'set it in a vault file' @@ -22,7 +21,7 @@ open_asfa_db_user: 'asfadb_user' open_asfa_db_volume: 'asfa_pg_data' open_asfa_db_allowed_hosts: - '127.0.0.1/8' -open_asfa_db_constraints: '[node.labels.pg_data==asfa_server]' +open_asfa_db_constraints: '[node.labels.pg_data==asfa_server_test]' open_asfa_psql_db_data: - { db_host: '{{ open_asfa_db_host }}', pgsql_version: '{{ open_asfa_db_pg_version }}', name: '{{ open_asfa_db_name }}', encoding: 'UTF8', user: '{{ open_asfa_db_user }}', roles: 'CREATEDB,NOSUPERUSER', pwd: '{{ open_asfa_db_pwd }}', allowed_hosts: '{{ open_asfa_db_allowed_hosts }}' } diff --git a/tasks/main.yml b/tasks/main.yml index 9fd35d4..184c87b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,21 +9,30 @@ run_once: True when: - - open_asfa_docker_db_node is defined and open_asfa_docker_db_node + - open_asfa_db_docker_host == ansible_fqdn - open_asfa_db_as_container tags: [ 'open_asfa', 'open_asfa_swarm', 'open_asfa_db' ] - name: Manage the installation of the OpenASFA configuration of the swarm service block: - - name: Install the docker compose file - template: src=open-asfa-docker-compose.yml.j2 dest={{ open_asfa_compose_dir }}/docker-open-asfa-stack.yml owner=root group=root mode='0400' + - name: Add the label that will be used as a constraint for the PostgreSQL DB + docker_node: + hostname: '{{ open_asfa_db_docker_host }}' + #node.labels.pg_data==asfa_server_test + labels: + pg_data: 'asfa_server_test' + labels_state: 'merge' + when: open_asfa_db_as_container - - name: Start the OpenAsfa stack + - name: Install the docker compose file + template: src=open-asfa-docker-compose.yml.j2 dest={{ open_asfa_compose_dir }}/docker-open-asfa-stack-test.yml owner=root group=root mode='0400' + + - name: Start the OpenAsfa stack docker_stack: - name: open-asfa + name: open-asfa-test state: present compose: - - '{{ open_asfa_compose_dir }}/docker-open-asfa-stack.yml' + - '{{ open_asfa_compose_dir }}/docker-open-asfa-stack-test.yml' run_once: True when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool