Additional custom /etc/hosts entries.

This commit is contained in:
Andrea Dell'Amico 2025-06-05 13:11:54 +02:00
parent b9aff40306
commit 3c8db06b4f
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
2 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,7 @@ sysctl_custom_file: /etc/sysctl.d/90-custom-values.conf
sysctl_opts_reload: yes
sysctl_custom_file_state: present
custom_etc_hosts_entries: ""
custom_etc_hosts_entries_adjunct: ""
# Only name and value are mandatory. The others have defaults
sysctl_custom_options: []

View File

@ -26,3 +26,32 @@
marker: "# {mark} hosts entries managed by ansible"
block: "{{ custom_etc_hosts_entries }}"
state: absent
- name: etchosts-customizations | Additional custom entries to /etc/hosts
when: custom_etc_hosts_entries_adjunct | length > 0
tags:
- etchosts
block:
- name: etchosts-customizations | Additional custom entries to /etc/hosts
ansible.builtin.blockinfile:
path: /etc/hosts
marker_begin: 'ansible_etchosts_adjunct_start'
marker_end: 'ansible_etchosts_adjunct_end'
marker: "# {mark} additional hosts entries managed by ansible"
block: "{{ custom_etc_hosts_entries_adjunct }}"
state: present
- name: etchosts-customizations | Remove entries from /etc/hosts
when: custom_etc_hosts_entries_adjunct | length == 0
tags:
- etchosts
block:
- name: etchosts-customizations | Remove the additional custom entries from /etc/hosts
ansible.builtin.blockinfile:
path: /etc/hosts
marker_begin: 'ansible_etchosts_adjunct_start'
marker_end: 'ansible_etchosts_adjunct_end'
marker: "# {mark} additional hosts entries managed by ansible"
block: "{{ custom_etc_hosts_entries_adjunct }}"
state: absent