-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure.yml
51 lines (43 loc) · 1.38 KB
/
azure.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- hosts: all
become: true
# Gathering facts must be disable on the playbook and run manually after the
# VMs was powered on. This to avoid marking the VM immediately as "not
# reachable" and skipped in all other tasks.
gather_facts: false
tasks:
# This task must be run only once, and the role will perform its tasks on
# localhost, so we can run the power on tasks also on an inventory of
# powered off VMs
- name: "Power on Azure VMs"
include_role:
name: azure
tasks_from: power
vars:
vm_list: "{{ groups['base'] }}"
status: on
when:
- azure_vm_keep_running is defined
run_once: true
# After the VMs was powered on, we can gather facts from hosts
- name: "Gathering host facts"
gather_facts:
# Here we start the "normal" playbook operations
- name: "Import base variables"
include_vars: base.yaml
- import_role:
name: my-first-role
- import_role:
name: my-second-role
# Then we can proceed to power off all the VMs. This task also need to be
# run only once, and it will performed on localhost
- name: "Power off Azure VMs"
include_role:
name: azure
tasks_from: power
vars:
vm_list: "{{ groups['base'] }}"
status: off
when:
- azure_vm_keep_running is defined
run_once: true