init
This commit is contained in:
23
roles/hostname/tasks/main.yaml
Normal file
23
roles/hostname/tasks/main.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
- name: Set a hostname via hostnamectl
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ server_hostname }}"
|
||||
use: systemd
|
||||
when: ansible_virtualization_type == "kvm" or
|
||||
ansible_virtualization_type == "openstack" or
|
||||
ansible_virtualization_type == "NA"
|
||||
|
||||
- name: Set a hostname and FQDN in /etc/hosts
|
||||
ansible.builtin.template:
|
||||
src: hosts
|
||||
dest: /etc/hosts
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Set a hostname in /etc/hostname
|
||||
ansible.builtin.template:
|
||||
src: hostname
|
||||
dest: /etc/hostname
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
1
roles/hostname/templates/hostname
Normal file
1
roles/hostname/templates/hostname
Normal file
@ -0,0 +1 @@
|
||||
{{ server_hostname }}
|
10
roles/hostname/templates/hosts
Normal file
10
roles/hostname/templates/hosts
Normal file
@ -0,0 +1,10 @@
|
||||
# Ansible managed
|
||||
|
||||
127.0.0.1 localhost
|
||||
::1 localhost6
|
||||
127.0.0.1 {{ server_fqdn }} {{ server_hostname }}
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
Reference in New Issue
Block a user