545ee33d54e353b24bb01d0137e4b5daa898ff6d
[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     - sysctl:
11         name: net.ipv4.ip_forward
12         state: present
13         value: 1
14         sysctl_set: yes
15     - systemd:
16         name: dhcpd
17         state: stopped
18         enabled: no
19       ignore_errors: yes
20     - systemd:
21         name: libvirtd
22         state: started
23         enabled: yes
24     - systemd:
25         name: openvswitch
26         state: started
27         enabled: yes
28     - virt_net:
29         command: define
30         name: default
31         xml: '{{ lookup("template", "virsh_network_default.xml.j2") }}'
32         state: active
33         autostart: yes
34     - openvswitch_bridge:
35         bridge: 'br-{{ item }}'
36         state: present
37       with_items: '{{ virsh_enabled_networks }}'
38     - virt_net:
39         state: present
40         name: '{{ item }}'
41         xml: '{{ lookup("template", "virsh_network_ovs.xml.j2") }}'
42       with_items: '{{ virsh_enabled_networks }}'
43     - virt_net:
44         state: active
45         name: '{{ item }}'
46         autostart: yes
47       with_items: '{{ virsh_enabled_networks }}'
48     - virt_pool:
49         name: default
50         autostart: yes
51         state: present
52         xml: '{{ lookup("template", "virsh_pool.xml.j2") }}'
53     - virt_pool:
54         name: default
55         autostart: yes
56         state: active
57     - shell: cat /sys/module/kvm_intel/parameters/nested || true
58       register: nested_result
59       when: ansible_architecture == "x86_64"
60     - name: reload kvm_intel
61       block:
62         - lineinfile:
63             path: /etc/modprobe.d/kvm_intel.conf
64             line: 'options kvm-intel nested=1'
65             create: yes
66         - modprobe:
67             name: kvm_intel
68             state: absent
69         - modprobe:
70             name: kvm_intel
71             state: present
72       when:
73         - ansible_architecture == "x86_64"
74         - "'Y' not in nested_result.stdout"
75     - name: Generate SSH key for root if missing
76       shell: test -e ~/.ssh/id_rsa || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
77     - name: Check that /u/l/python3.4/site-packages/virtualbmc/vbmc.py exists
78       stat:
79         path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
80       register: vbmc_py
81     - name: Manually patch vmbc to work with python3.x
82       lineinfile:
83         line: "                conn.defineXML(ET.tostring(tree, encoding='unicode'))"
84         regexp: "tostring"
85         path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
86       when: vbmc_py.stat.exists == True
87     - name: Add ssh retry to Ansible config
88       ini_file:
89         path: /etc/ansible/ansible.cfg
90         section: ssh_connection
91         option: retries
92         value: 5