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