installer role works now but still has issues
[noc.git] / ansible / vm-install.yml
1 ---
2 - name: preperations and sanity checks
3   hosts: "{{ vmname }}"
4   gather_facts: no
5   tasks:
6   - name: setup variables
7     set_fact:
8       vm_network_cooked: "{{ vm_network }}"
9       vm_install_cooked: "{{ vm_install }}"
10   - name: create temporary host group for vm host
11     add_host:
12       name: "{{ vm_install.host }}"
13       inventory_dir: "{{inventory_dir}}"
14       group: _vmhost_
15   # TODO: add some sanity checks
16
17 - name: basic installation
18   hosts: _vmhost_
19   roles:
20   - role: vm-install
21
22 - name: wait for new vm to start up
23   hosts: "{{ vmname }}"
24   gather_facts: no
25   tasks:
26     ## TODO: find a better way to fetch host key of new VMs
27   - name: disable ssh StrictHostKeyChecking for the next step
28     set_fact:
29       ansible_ssh_extra_args: -o StrictHostKeyChecking=no
30   - name: wait for vm to start up
31     wait_for_connection:
32       delay: 5
33       timeout: 120
34   - name: reenable StrictHostKeyChecking
35     set_fact:
36       ansible_ssh_extra_args: ""
37
38 - import_playbook: "host_playbooks/{{ vmname }}.yml"
39
40 - name: reboot and wait for VM come back
41   hosts: "{{ vmname }}"
42   gather_facts: no
43   roles:
44   - role: reboot-and-wait
45     reboot_delay: 10
46     reboot_timeout: 120