summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/become/tasks/become.yml
blob: d31634fc74e46d330e0eca6035e68945a002cfb5 (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
38
39
40
41
42
43
44
45
46
47
48
49
- name: test becoming user ({{ become_test }})
  raw: whoami
  register: whoami

- name: implicit tilde expansion reflects become user ({{ become_test }})
  stat:
    path: "~"
  register: stat_home_implicit

- name: explicit tilde expansion reflects become user ({{ become_test }})
  stat:
    path: "~{{ ansible_become_user }}"
  register: stat_home_explicit

- name: put a file ({{ become_test }})
  copy:
    src: copy.txt
    dest: "~{{ ansible_become_user }}/{{ ansible_become_method }}-{{ ansible_become_user }}-copy.txt"
  register: put_file

- name: fetch a file ({{ become_test }})
  fetch:
    src: "~{{ ansible_become_user }}/{{ ansible_become_method }}-{{ ansible_become_user }}-copy.txt"
    dest: "{{ output_dir }}"
  register: fetch_file

- name: explicit tilde expansion reflects become user ({{ become_test }})
  stat:
    path: "~{{ ansible_become_user }}/{{ ansible_become_method }}-{{ ansible_become_user }}-copy.txt"
  register: stat_file

- name: verify results from previous tasks ({{ become_test }})
  assert:
    that:
      - "whoami.stdout|trim == ansible_become_user"

      - "stat_home_implicit.stat.exists == True"
      - "stat_home_implicit.stat.path|basename == ansible_become_user"

      - "stat_home_explicit.stat.exists == True"
      - "stat_home_explicit.stat.path|basename == ansible_become_user"

      - "put_file.uid == test_user.uid"
      - "put_file.gid == test_user.group"

      - "fetch_file.remote_checksum == put_file.checksum"

      - "stat_file.stat.exists == True"
      - "stat_file.stat.path|dirname|basename == ansible_become_user"