blob: ab09ff6e7fe883c2e2ea68fb4a9a1ac60d3df9bb (
plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
---
- hosts: localhost
tasks:
- yum:
name: "{{ item }}"
state: present
with_items:
- python-lxml
- libvirt-python
- libguestfs-tools
- python-netaddr
- python2-pip
when: ansible_distribution == 'CentOS'
- dnf:
name: "{{ item }}"
state: present
with_items:
- libselinux-python
- python-lxml
- libvirt-python
- libguestfs-tools
- python-netaddr
- python2-pip
when: ansible_distribution == 'Fedora'
- pip:
name: ansible-modules-hashivault,hvac,Jinja2
state: latest
executable: pip2
when: not snapshot
- sysctl:
name: net.ipv4.ip_forward
state: present
value: 1
sysctl_set: yes
- systemd:
name: dhcpd
state: stopped
enabled: no
ignore_errors: yes
- systemd:
name: libvirtd
state: started
enabled: yes
- systemd:
name: openvswitch
state: started
enabled: yes
- virt_net:
command: define
name: default
xml: '{{ lookup("template", "virsh_network_default.xml.j2") }}'
state: active
autostart: yes
when: not snapshot
- openvswitch_bridge:
bridge: 'br-{{ item }}'
state: present
with_items: '{{ virsh_enabled_networks }}'
- name: 'Configure IP on bridge'
shell: 'ip addr add 192.0.2.99/24 dev br-{{ item }}'
with_items: '{{ virsh_enabled_networks }}'
when: snapshot
- name: 'Bring up bridge'
shell: 'ip link set up br-{{ item }}'
with_items: '{{ virsh_enabled_networks }}'
when: snapshot
- virt_net:
state: present
name: '{{ item }}'
xml: '{{ lookup("template", "virsh_network_ovs.xml.j2") }}'
with_items: '{{ virsh_enabled_networks }}'
when: not snapshot
- virt_net:
state: active
name: '{{ item }}'
autostart: yes
with_items: '{{ virsh_enabled_networks }}'
when: not snapshot
- virt_pool:
name: default
autostart: yes
state: present
xml: '{{ lookup("template", "virsh_pool.xml.j2") }}'
- virt_pool:
name: default
autostart: yes
state: active
- shell: cat /sys/module/kvm_intel/parameters/nested || true
register: nested_result
when: ansible_architecture == "x86_64"
- name: reload kvm_intel
block:
- lineinfile:
path: /etc/modprobe.d/kvm_intel.conf
line: 'options kvm-intel nested=1'
create: yes
- modprobe:
name: kvm_intel
state: absent
- modprobe:
name: kvm_intel
state: present
when:
- ansible_architecture == "x86_64"
- "'Y' not in nested_result.stdout"
- modprobe:
name: ip6_tables
state: present
- modprobe:
name: ip_tables
state: present
- name: Generate SSH key for root if missing
shell: test -e ~/.ssh/id_rsa || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
when: not snapshot
- name: Check that /u/l/python3.4/site-packages/virtualbmc/vbmc.py exists
stat:
path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
register: vbmc_py
when: not snapshot
- name: Manually patch vmbc to work with python3.x
lineinfile:
line: " conn.defineXML(ET.tostring(tree, encoding='unicode'))"
regexp: "tostring"
path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
when: vbmc_py.stat.exists == True
when: not snapshot
- name: Add ssh retry to Ansible config
ini_file:
path: /etc/ansible/ansible.cfg
section: ssh_connection
option: retries
value: 5
|