blob: 5adfb13d6dd08dff07adfc96172b334c4037a94e (
plain)
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
|
- name: gather distribution facts
gather_facts:
gather_subset: distribution
when: ansible_distribution is not defined
- name: include distribution specific tasks
include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution | lower }}.yml"
- default.yml
paths:
- tasks
- name: create test user
user:
name: "{{ test_user_name }}"
group: "{{ test_user_group or omit }}"
password: "{{ test_user_hashed_password or omit }}"
register: test_user
notify:
- delete test user
- name: run whoami as the test user
shell: whoami
vars:
# ansible_become_method and ansible_become_flags are not set, allowing them to be provided by inventory
ansible_become: yes
ansible_become_user: "{{ test_user_name }}"
ansible_become_password: "{{ test_user_plaintext_password }}"
register: whoami
- name: verify becoming the test user worked
assert:
that:
- whoami.stdout == test_user_name
|