torwachter: rm d3 key as he does no longer want access as told by ruru. Also better...
[noc.git] / ansible / vm-install.yml
1 ---
2 - name: preperations and sanity checks
3   hosts: "{{ hostname }}"
4   gather_facts: no
5   tasks:
6   - name: setup variables
7     set_fact:
8       network_cooked: "{{ network }}"
9       install_cooked: "{{ install }}"
10   - name: create temporary host group for vm host
11     add_host:
12       name: "{{ vm_host }}"
13       inventory_dir: "{{inventory_dir}}"
14       group: _vmhost_
15   # TODO: add some sanity checks
16
17 - import_playbook: remove_known_hosts.yml
18
19 - name: basic installation
20   hosts: _vmhost_
21   roles:
22   - role: vm/install
23
24 - name: wait for new vm to start up
25   hosts: "{{ hostname }}"
26   gather_facts: no
27   tasks:
28     ## TODO: find a better way to fetch host key of new VMs
29   - name: disable ssh StrictHostKeyChecking for the next step
30     set_fact:
31       ansible_ssh_extra_args: -o StrictHostKeyChecking=no
32   - name: wait for vm to start up
33     wait_for_connection:
34       delay: 5
35       timeout: 120
36   - name: reenable StrictHostKeyChecking
37     set_fact:
38       ansible_ssh_extra_args: ""
39
40 - name: Apply VM configuration roles
41   hosts: "{{ hostname }}"
42   pre_tasks:
43   - name: make sure to update cached facts
44     setup:
45   roles:
46   - role: vm/grub
47   - role: vm/network
48   - role: vm/guest
49
50 - import_playbook: "host_playbooks/{{ hostname }}.yml"
51
52 - name: reboot and wait for VM come back
53   hosts: "{{ hostname }}"
54   gather_facts: no
55   roles:
56   - role: reboot-and-wait
57     reboot_delay: 10
58     reboot_timeout: 120