22 lines
1.4 KiB
YAML
22 lines
1.4 KiB
YAML
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# Configure HOSTNAME and HOSTS with new HOSTNAME
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# Configure HOSTNAME /etc/hostname
|
|
- name: Set a hostname specifying strategy in /etc/hostname
|
|
ansible.builtin.hostname:
|
|
name: "{{ name_hostname }}"
|
|
use: debian
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
- name: Replace old hostname with new hostname in /etc/hosts
|
|
lineinfile:
|
|
dest: /etc/hosts
|
|
regexp: '^127\.0\.1\.1\tplantilladebian12\.verdnatura\.es\tplantilladebian12'
|
|
line: '127.0.1.1 {{ name_hostname }}.verdnatura.es {{ name_hostname }}'
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/hostname_module.html#ansible-collections-ansible-builtin-hostname-module
|
|
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html#ansible-collections-ansible-builtin-replace-module
|
|
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html#ansible-collections-ansible-builtin-lineinfile-module
|