ansible-role-basic-system-s.../tasks/etchosts-customizations.yml

29 lines
1.0 KiB
YAML

---
- name: etchosts-customizations | Add entries to /etc/hosts
when: custom_etc_hosts_entries | length > 0
tags:
- etchosts
block:
- name: etchosts-customizations | Add custom entries to /etc/hosts
ansible.builtin.blockinfile:
path: /etc/hosts
marker_begin: 'ansible_etchosts_customizations_start'
marker_end: 'ansible_etchosts_customizations_end'
marker: "# {mark} hosts entries managed by ansible"
block: "{{ custom_etc_hosts_entries }}"
state: present
- name: etchosts-customizations | Remove entries from /etc/hosts
when: custom_etc_hosts_entries | length == 0
tags:
- etchosts
block:
- name: etchosts-customizations | Remove custom entries from /etc/hosts
ansible.builtin.blockinfile:
path: /etc/hosts
marker_begin: 'ansible_etchosts_customizations_start'
marker_end: 'ansible_etchosts_customizations_end'
marker: "# {mark} hosts entries managed by ansible"
block: "{{ custom_etc_hosts_entries }}"
state: absent