-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbootstrap_vm_template.yml
141 lines (126 loc) · 4.93 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
- name: "Apply host to vm_template root group"
tags: always
hosts: localhost
connection: local
tasks:
- name: "Set vm_template_group"
ansible.builtin.set_fact:
vm_template_group: "vm_template"
- name: "Display vm_template_group"
ansible.builtin.debug:
var: vm_template_group
- name: "Apply group {{ vm_template_group }} to hosts"
changed_when: no
ansible.builtin.group_by:
key: "{{ vm_template_group }}"
- name: "Display cacert_keystore_host"
ansible.builtin.debug:
var: cacert_keystore_host
- name: "Gather facts for all hosts to apply OS specific group vars for them"
tags: always
hosts: vm_template
connection: local
roles:
- role: apply_common_groups
- name: "Apply host to vm_template group(s)"
tags: always
hosts: localhost
connection: local
tasks:
- name: "Set vm_template_group"
ansible.builtin.set_fact:
vm_template_group: vm_template_{{ dc_os_family }}
- 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: "Display ansible_python_interpreter"
ansible.builtin.debug:
var: ansible_python_interpreter
- name: "Display ansible_virtualenv_python_interpreter"
ansible.builtin.debug:
var: ansible_virtualenv_python_interpreter
- name: "Display important collection versions"
hosts: localhost
connection: local
tags:
- always
- display-collection-versions
vars:
ansible_python_interpreter: "{{ os_python_interpreter }}"
ansible_user: "{{ bootstrap_user }}"
# ansible_password: "{{ bootstrap_user_password }}"
tasks:
- name: "Display important collection versions" # noqa run-once[task]
run_once: true
ansible.builtin.debug:
msg:
- "ansible.controller version={{ lookup('community.general.collection_version', 'ansible.controller') }}"
- "ansible.posix version={{ lookup('community.general.collection_version', 'ansible.posix') }}"
- "ansible.tower version={{ lookup('community.general.collection_version', 'ansible.tower') }}"
- "ansible.utils version={{ lookup('community.general.collection_version', 'ansible.utils') }}"
- "ansible.windows version={{ lookup('community.general.collection_version', 'ansible.windows') }}"
- "community.crypto version={{ lookup('community.general.collection_version', 'community.crypto') }}"
- "community.docker version={{ lookup('community.general.collection_version', 'community.docker') }}"
- "community.general version={{ lookup('community.general.collection_version', 'community.general') }}"
- "community.postgresql version={{ lookup('community.general.collection_version', 'community.postgresql') }}"
- "community.vmware version={{ lookup('community.general.collection_version', 'community.vmware') }}"
- "community.windows version={{ lookup('community.general.collection_version', 'community.windows') }}"
- "confluent.platform version={{ lookup('community.general.collection_version', 'confluent.platform') }}"
- "cyberark.conjur version={{ lookup('community.general.collection_version', 'cyberark.conjur') }}"
- "cyberark.pas version={{ lookup('community.general.collection_version', 'cyberark.pas') }}"
- "microsoft.ad version={{ lookup('community.general.collection_version', 'microsoft.ad') }}"
- name: Bootstrap ansible venv
hosts: vm_template_linux
tags:
- vm-template
- bootstrap-ansible-venv
- bootstrap-pip
- bootstrap-linux-docker
- bootstrap-docker
become: true
vars:
ansible_python_interpreter: "{{ os_python_interpreter }}"
bootstrap_pip__env_force_rebuild: false
ansible_become: true
ansible_become_user: root
ansible_become_method: ansible.builtin.sudo
roles:
- role: bootstrap_pip
- name: Bootstrap linux OS on vm template
hosts: vm_template_linux
tags:
- vm-template
- bootstrap-vm-template
- bootstrap-linux-template
connection: local
become: true
become_user: root
become_method: ansible.builtin.sudo
vars:
ansible_user: "{{ bootstrap_user }}"
ansible_python_interpreter: "{{ ansible_virtualenv_python_interpreter }}"
# ansible_user: "{{ lookup('env', 'USER') }}"
# ansible_python_interpreter: "{{ os_python_interpreter }}"
ansible_become: true
ansible_become_user: root
ansible_become_method: ansible.builtin.sudo
roles:
- role: bootstrap_linux
- name: Bootstrap Windows OS on vm template
hosts: vm_template_windows
tags:
- vm-template
- bootstrap-vm-template
- bootstrap-windows-template
connection: local
become: true
roles:
- role: bootstrap_windows