torwaechter: fix bug in tuergit hook script that prevent script from executing
[noc.git] / ansible / vm-update.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
11   - name: create temporary host group for vm host
12     changed_when: no
13     add_host:
14       name: "{{ install_cooked.host }}"
15       inventory_dir: "{{inventory_dir}}"
16       group: _vmhost_
17   # TODO: add some sanity checks
18
19 - name: Update network configuration & shutdown VM
20   hosts: "{{ hostname }}"
21   roles:
22     - vm/network
23
24   post_tasks:
25     - name: Shutdown VM
26       async: 1
27       poll: 0
28       ignore_errors: true
29       shell: sleep 2 && poweroff
30
31 - name: Update VM definition
32   hosts: _vmhost_
33   pre_tasks:
34     - name: Wait for VM to shut down
35       wait_for_virt:
36         name: "{{ hostname }}"
37         states: shutdown
38         timeout: 30
39
40   roles:
41     - vm/define
42
43 - name: Apply the base vm/guest role
44   hosts: "{{ hostname }}"
45   pre_tasks:
46     - name: Wait for the VM to be up and running
47       wait_for_connection:
48         timeout: 120
49
50   roles:
51     - vm/guest