Skip to content

Commit 6e38085

Browse files
committed
fix etc_hosts_template
1 parent 2657d78 commit 6e38085

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

environments/common/inventory/group_vars/all/cloud_init.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
cloud_init_output_path: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/cloud_init"
22

3+
etc_hosts_template: |
4+
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
5+
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
6+
7+
{% for hostname in groups['etc_hosts'] | sort -%}
8+
{{ hostvars[hostname]['ansible_host'] }} {{ hostname }}
9+
{% endfor -%}
10+
311
cloud_init_userdata_etchosts:
412
module: write_files
513
group: etc_hosts
@@ -10,12 +18,7 @@ cloud_init_userdata_etchosts:
1018
permissions: "0644"
1119
owner: root:root
1220
content: |
13-
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
14-
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
15-
16-
{% for hostname in groups['etc_hosts'] | sort -%}
17-
{{ hostvars[hostname]['ansible_host'] }} {{ hostname }}
18-
{% endfor -%}
21+
{{ etc_hosts_template | indent(width=6, first=false) }}
1922
2023
cloud_init_userdata_templates_default: # provides indirection so environments could copy parts of default without having to rewrite the entire thing
2124
- "{{ cloud_init_userdata_etchosts }}"

0 commit comments

Comments
 (0)