feat: added hosts file management
This commit is contained in:
parent
681d0f80cf
commit
262333ab70
2 changed files with 13 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ This role manages the build-in 'core' Operating System components and defaults t
|
|||
- cron
|
||||
- environment-file
|
||||
- hostname
|
||||
- hostfile
|
||||
- firewall
|
||||
- journald
|
||||
- locale
|
||||
|
|
|
|||
|
|
@ -3,7 +3,18 @@
|
|||
# set hostname
|
||||
- name: "set hostname"
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ set_hostname | default(inventory_hostname) }}"
|
||||
name: "{{ set_hostname | default(inventory_hostname_short) }}"
|
||||
use: "{{ hostname_use_method }}"
|
||||
tags:
|
||||
- "hostname"
|
||||
|
||||
# manage /etc/hosts file
|
||||
- name: "manage /etc/hosts file for hostname"
|
||||
ansible.builtin.lineinfile:
|
||||
path: "/etc/hosts"
|
||||
regexp: '^{{ ansible_default_ipv4.address }}\s+.*{{ inventory_hostname_short }}.*$'
|
||||
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }} {{ inventory_hostname_short }}"
|
||||
backup: true
|
||||
tags:
|
||||
- "hostfile"
|
||||
- "hostname"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue