Fixes broken compute role update
[apex.git] / lib / ansible / playbooks / deploy_dependencies.yml
1 ---
2 - hosts: localhost
3   tasks:
4     - yum:
5         name: "{{ item }}"
6         state: present
7       with_items:
8         - python-lxml
9         - libvirt-python
10         - libguestfs-tools
11         - python-netaddr
12         - python2-pip
13       when: ansible_distribution == 'CentOS'
14     - dnf:
15         name: "{{ item }}"
16         state: present
17       with_items:
18         - libselinux-python
19         - python-lxml
20         - libvirt-python
21         - libguestfs-tools
22         - python-netaddr
23         - python2-pip
24       when: ansible_distribution == 'Fedora'
25     - pip:
26         name: ansible-modules-hashivault,hvac,Jinja2
27         state: latest
28         executable: pip2
29       when: not snapshot
30     - sysctl:
31         name: net.ipv4.ip_forward
32         state: present
33         value: 1
34         sysctl_set: yes
35     - systemd:
36         name: dhcpd
37         state: stopped
38         enabled: no
39       ignore_errors: yes
40     - systemd:
41         name: libvirtd
42         state: started
43         enabled: yes
44     - systemd:
45         name: openvswitch
46         state: started
47         enabled: yes
48     - virt_net:
49         command: define
50         name: default
51         xml: '{{ lookup("template", "virsh_network_default.xml.j2") }}'
52         state: active
53         autostart: yes
54       when: not snapshot
55     - openvswitch_bridge:
56         bridge: 'br-{{ item }}'
57         state: present
58       with_items: '{{ virsh_enabled_networks }}'
59     - name: 'Configure IP on bridge'
60       shell: 'ip addr add  192.0.2.99/24 dev br-{{ item }}'
61       with_items: '{{ virsh_enabled_networks }}'
62       when: snapshot
63     - name: 'Bring up bridge'
64       shell: 'ip link set up br-{{ item }}'
65       with_items: '{{ virsh_enabled_networks }}'
66       when: snapshot
67     - virt_net:
68         state: present
69         name: '{{ item }}'
70         xml: '{{ lookup("template", "virsh_network_ovs.xml.j2") }}'
71       with_items: '{{ virsh_enabled_networks }}'
72       when: not snapshot
73     - virt_net:
74         state: active
75         name: '{{ item }}'
76         autostart: yes
77       with_items: '{{ virsh_enabled_networks }}'
78       when: not snapshot
79     - virt_pool:
80         name: default
81         autostart: yes
82         state: present
83         xml: '{{ lookup("template", "virsh_pool.xml.j2") }}'
84     - virt_pool:
85         name: default
86         autostart: yes
87         state: active
88     - shell: cat /sys/module/kvm_intel/parameters/nested || true
89       register: nested_result
90       when: ansible_architecture == "x86_64"
91     - name: reload kvm_intel
92       block:
93         - lineinfile:
94             path: /etc/modprobe.d/kvm_intel.conf
95             line: 'options kvm-intel nested=1'
96             create: yes
97         - modprobe:
98             name: kvm_intel
99             state: absent
100         - modprobe:
101             name: kvm_intel
102             state: present
103       when:
104         - ansible_architecture == "x86_64"
105         - "'Y' not in nested_result.stdout"
106     - modprobe:
107         name: ip6_tables
108         state: present
109     - modprobe:
110         name: ip_tables
111         state: present
112     - name: Generate SSH key for root if missing
113       shell: test -e ~/.ssh/id_rsa || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
114       when: not snapshot
115     - name: Check that /u/l/python3.4/site-packages/virtualbmc/vbmc.py exists
116       stat:
117         path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
118       register: vbmc_py
119       when: not snapshot
120     - name: Manually patch vmbc to work with python3.x
121       lineinfile:
122         line: "                conn.defineXML(ET.tostring(tree, encoding='unicode'))"
123         regexp: "tostring"
124         path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
125       when: vbmc_py.stat.exists == True
126       when: not snapshot
127     - name: Add ssh retry to Ansible config
128       ini_file:
129         path: /etc/ansible/ansible.cfg
130         section: ssh_connection
131         option: retries
132         value: 5