playbook and rol config hostname
This commit is contained in:
parent
1ad0eb9629
commit
3ab737b107
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: '{{ ip_addr }}'
|
||||||
|
become: yes
|
||||||
|
become_method: sudo
|
||||||
|
gather_facts: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: "[CONFIG HOSTNAME] Configure hostname"
|
||||||
|
import_role:
|
||||||
|
name: config-hostname
|
|
@ -0,0 +1,21 @@
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
# 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
|
Loading…
Reference in New Issue