1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
- name: "create file: /etc/hostname"
copy:
content: "{{system.hostname}}"
dest: /etc/hostname
register: hostnameFile
when: system.hostname is defined
- name: Change hostname of running system
hostname:
name: "{{system.hostname}}"
when:
- system.hostname is defined
- hostnameFile.changed
- name: "create file: /etc/hosts"
template:
src: hosts.conf.j2
dest: /etc/hosts
mode: 0755
when: system.hostname is defined
- name: "create file: /etc/resolv.conf"
template:
src: resolv.conf.j2
dest: /etc/resolv.conf
mode: 0755
when: system.nameservers is defined