Files
Ansible-roles/common/tasks/cloud_init.yml
T

16 lines
696 B
YAML

# With manage_etc_hosts in the user-data (Proxmox sets it) cloud-init rewrites /etc/hosts from its
# template on every boot and drops the blocks other roles add; user-data outranks cloud.cfg.d, so
# the module is taken out of the boot stage instead.
- name: Read the cloud-init configuration
slurp:
path: /etc/cloud/cloud.cfg
register: cloud_cfg
failed_when: false
- name: Keep cloud-init from rewriting /etc/hosts
when: cloud_cfg.content is defined
copy:
dest: /etc/cloud/cloud.cfg.d/99-ansible-etc-hosts.cfg
content: |
cloud_init_modules: {{ (cloud_cfg.content | b64decode | from_yaml).cloud_init_modules | reject('equalto', 'update_etc_hosts') | list | to_json }}