-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNetwork.yml
75 lines (70 loc) · 1.91 KB
/
Network.yml
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- name: login as controller
hosts: controller
remote_user: root
become: yes
tasks:
- name: update network interface
lineinfile:
dest: /etc/network/interfaces
regexp: 'iface lo inet loopback'
line: "{{ item }}"
with_items:
- 'auto enp0s3'
- 'iface enp0s3 inet static'
- ' address 172.16.18.18'
- ' netmask 255.255.255.0'
- ' gateway 172.16.18.1'
- ' dns-nameservers 192.168.1.10'
- 'auto enp0s8'
- ' iface enp0s8 inet static'
- ' address 10.0.0.11'
- ' netmask 255.255.255.0'
- name: network restart
service:
name: networking
state: restarted
- name: login as compute
hosts: compute
remote_user: root
become: yes
tasks:
- name: update compute network interface
lineinfile:
dest: /etc/network/interfaces
insertafter: EOF
line: "{{ item }}"
with_items:
- 'auto enp0s3'
- 'iface enp0s3 inet static'
- ' address 172.16.18.19'
- ' netmask 255.255.255.0'
- ' gateway 172.16.18.1'
- ' dns-nameservers 192.168.1.10'
- 'auto enp0s8'
- ' iface enp0s8 inet static'
- ' address 10.0.0.31'
- ' netmask 255.255.255.0'
- name: network restart
service:
name: networking
state: restarted
- hosts: all
tasks:
- name: Update Hosts File
lineinfile:
dest: /etc/hosts
regexp: 'ff02::2 ip6-allrouters'
line: "{{ item }}"
with_items:
- '# Controller'
- '10.0.0.11 controller'
- '# Compute'
- '10.0.0.31 compute'
- hosts: all
tasks:
- name: Update Hosts File
lineinfile:
dest: /etc/hosts
regexp: '(.*127.0.0.1.*)'
replace: '#\1'