forked from linux-system-roles/ad_integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_include_vars_from_parent.yml
More file actions
48 lines (47 loc) · 2.06 KB
/
tests_include_vars_from_parent.yml
File metadata and controls
48 lines (47 loc) · 2.06 KB
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
---
- name: Test role inclusion variable overrides
hosts: all,!ad
gather_facts: true
tasks:
- name: Create var file in caller that can override the one in called role
delegate_to: localhost
copy:
# usually the fake file will cause the called role to crash of
# overriding happens, but if not, set a variable that will
# allow to detect the bug
content: "__caller_override: true"
# XXX ugly, self-modifying code - changes the "caller" role on
# the controller
dest: "{{ playbook_dir }}/roles/caller/vars/{{ item }}.yml"
mode: preserve
loop: "{{ varfiles | unique }}"
# In case the playbook is executed against multiple hosts, use
# only the first one. Otherwise the hosts would stomp on each
# other since they are changing files on the controller.
when: inventory_hostname == ansible_play_hosts_all[0]
vars:
# change to hostvars['localhost']['ansible_facts'] to use the
# information for localhost
facts: "{{ ansible_facts }}"
versions:
- "{{ facts['distribution_version'] }}"
- "{{ facts['distribution_major_version'] }}"
separators: ["-", "_"]
# create all variants like CentOS, CentOS_8.1, CentOS-8.1,
# CentOS-8, CentOS-8.1
# more formally:
# {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
# {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}
# {{ ansible_facts['distribution'] }}
# {{ ansible_facts['os_family'] }}
# and the same for _ as separator.
varfiles: "{{ [facts['distribution']] | product(separators) |
map('join') | product(versions) | map('join') | list +
[facts['distribution'], facts['os_family']] }}"
- name: Import role
import_role:
name: caller
vars:
ad_integration_realm: "{{ __ad_integration_sample_realm }}"
ad_integration_password: Secret123
roletoinclude: linux-system-roles.ad_integration