diff --git a/group_vars/app_prod/vars.yml b/group_vars/app_prod/vars.yml index 10f66b9..fb98f9a 100644 --- a/group_vars/app_prod/vars.yml +++ b/group_vars/app_prod/vars.yml @@ -2,4 +2,4 @@ # code: language=ansible --- db_inventory_hostname: sapt-labp-db01 -db_host_ip: "{{ hostvars[db_inventory_hostname].ansible_default_ipv4.address }}" +db_host: "{{ hostvars[db_inventory_hostname].ansible_host }}" diff --git a/group_vars/app_stage/vars.yml b/group_vars/app_stage/vars.yml index b3c48bb..def112c 100644 --- a/group_vars/app_stage/vars.yml +++ b/group_vars/app_stage/vars.yml @@ -2,4 +2,4 @@ # code: language=ansible --- db_inventory_hostname: sapt-labs-db01 -db_host_ip: "{{ hostvars[db_inventory_hostname].ansible_default_ipv4.address }}" +db_host: "{{ hostvars[db_inventory_hostname].ansible_host }}" diff --git a/roles/apps/templates/compose-files/nextcloud.yml.j2 b/roles/apps/templates/compose-files/nextcloud.yml.j2 index cf776af..f573e62 100644 --- a/roles/apps/templates/compose-files/nextcloud.yml.j2 +++ b/roles/apps/templates/compose-files/nextcloud.yml.j2 @@ -13,7 +13,7 @@ services: image: nextcloud:{{ apps_vars.nextcloud.version }} restart: always environment: - POSTGRES_HOST: "{{ db_host_ip }}" + POSTGRES_HOST: "{{ db_host }}" POSTGRES_DB: nextcloud POSTGRES_USER: nextcloud POSTGRES_PASSWORD: {{ db_passwords.nextcloud }} @@ -56,4 +56,4 @@ networks: {{ apps_postfix_docker_network }}: external: true {{ apps_shared_docker_network }}: - external: true \ No newline at end of file + external: true diff --git a/roles/common/templates/etc/hosts.j2 b/roles/common/templates/etc/hosts.j2 index 96c08f5..7099f29 100644 --- a/roles/common/templates/etc/hosts.j2 +++ b/roles/common/templates/etc/hosts.j2 @@ -11,6 +11,8 @@ ff02::2 ip6-allrouters ff02::3 ip6-allhosts # Static hostnames for VMs -{% for host in groups[all] %} +{% for host in groups['all'] %} +{% if 'ansible_eth1' in hostvars[host] %} {{ hostvars[host].ansible_eth1.ipv4.address }} {{ hostvars[host].ansible_host }} +{% endif %} {% endfor %}