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
|
- cron
|
||||||
- environment-file
|
- environment-file
|
||||||
- hostname
|
- hostname
|
||||||
|
- hostfile
|
||||||
- firewall
|
- firewall
|
||||||
- journald
|
- journald
|
||||||
- locale
|
- locale
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,18 @@
|
||||||
# set hostname
|
# set hostname
|
||||||
- name: "set hostname"
|
- name: "set hostname"
|
||||||
ansible.builtin.hostname:
|
ansible.builtin.hostname:
|
||||||
name: "{{ set_hostname | default(inventory_hostname) }}"
|
name: "{{ set_hostname | default(inventory_hostname_short) }}"
|
||||||
use: "{{ hostname_use_method }}"
|
use: "{{ hostname_use_method }}"
|
||||||
tags:
|
tags:
|
||||||
- "hostname"
|
- "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