Skip to content

Commit 8e81713

Browse files
committed
Add example playbook for azure role
Added an example playbook demonstrating how to use the azure role.
1 parent 8887b6c commit 8e81713

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

azure.yml

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

0 commit comments

Comments
 (0)