summaryrefslogtreecommitdiffstats
path: root/roles/hostname/tasks/main.yml
blob: b6dc2cc1b663ab942185432e13d3f2cdbf465d2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
- name: "Configure /etc/hostname"
  become: true
  ansible.builtin.copy:
    dest: "/etc/hostname"
    mode: "0644"
    content: |
      {{ hostname }}
  when: hostname is defined

- name: "Configure /etc/hosts"
  become: true
  ansible.builtin.copy:
    dest: "/etc/hosts"
    mode: "0644"
    content: |
      127.0.0.1   localhost
      127.0.1.1   {{ hostname }}
      ::1         localhost ip6-localhost ip6-loopback
      ff02::1     ip6-allnodes
      ff02::2     ip6-allrouters
  when: hostname is defined