vn-ansible/roles/config-hostname/tasks/main.yaml

22 lines
1.4 KiB
YAML
Raw Normal View History

2024-02-12 12:03:22 +00:00
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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'
2024-02-12 12:24:32 +00:00
line: '127.0.1.1 {{ name_hostname }}.verdnatura.es {{ name_hostname }}'
2024-02-12 12:03:22 +00:00
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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