-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
75 lines (65 loc) · 1.78 KB
/
playbook.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: Configure servers
hosts: servers
become: yes
tasks:
- name: Set hostname
hostname:
name: '{{ hostname }}'
use: systemd
- name: Get active connections
shell: nmcli -t -f NAME c show --active
register: active_conns
- name: Create team interface
community.general.nmcli:
type: team
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
method4: '{{ item.method4 }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
method6: '{{ item.method6 }}'
runner: '{{ item.runner }}'
state: present
with_items:
- '{{ nmcli_team }}'
register: nicteam
- name: Add slaves
community.general.nmcli:
type: team-slave
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
master: '{{ item.master }}'
state: present
with_items:
- '{{ nmcli_team_slave }}'
- name: Create VLAN interface
community.general.nmcli:
type: vlan
conn_name: '{{ item.conn_name }}'
vlandev: '{{ item.dev }}'
vlanid: '{{ item.id }}'
method4: '{{ item.method4 }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
method6: '{{ item.method6 }}'
state: present
with_items:
- '{{ nmcli_vlan }}'
when: vlans
- name: UP team interface
shell: nmcli con up '{{ teamif }}'
when: nicteam.changed
- name: Delete default connections
community.general.nmcli:
conn_name: '{{ item.conn_name }}'
state: absent
with_items:
- '{{ default_conn }}'
when: active_conns.stdout.find('Wired connection') != -1
ignore_errors: yes
- name: Get all connections
shell: nmcli -t -f NAME c show
register: conns
- name: Show all connections
debug:
msg: '{{ conns.stdout_lines }}'