-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap_vm_template.yml
45 lines (39 loc) · 1.09 KB
/
bootstrap_vm_template.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
---
- name: Gather facts for all hosts to apply OS specific group vars for them
tags: always
hosts: ansible_localhost
roles:
- role: apply_common_groups
- name: Apply host to vm_template group(s)
tags: always
hosts: ansible_localhost
tasks:
- name: Set vm_template_group
ansible.builtin.set_fact:
vm_template_group: vm_template_{{ dc_os_family_shortname }}
- name: Display vm_template_group
ansible.builtin.debug:
var: vm_template_group
- name: Apply group {{ vm_template_group }} to hosts
changed_when: false
ansible.builtin.group_by:
key: "{{ vm_template_group }}"
- name: Display group_names
ansible.builtin.debug:
var: group_names | d([])
- name: Bootstrap linux OS on vm template
# hosts: os_linux
hosts: vm_template_linux
tags: vm-template
connection: local
become: true
roles:
- role: bootstrap_linux
- name: Bootstrap windows OS on vm template
# hosts: os_windows
hosts: vm_template_windows
tags: vm-template
connection: local
become: true
roles:
- role: bootstrap_windows