2017-08-01 05:07:22 +00:00
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: Create a local temporary directory
|
2018-01-16 05:15:04 +00:00
|
|
|
shell: mktemp -d /tmp/ansible_test.XXXXXXXXX
|
2017-08-01 05:07:22 +00:00
|
|
|
register: tempfile_result
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
local_temp_dir: '{{ tempfile_result.stdout }}'
|
|
|
|
# output_dir is hardcoded in test/runner/lib/executor.py and created there
|
|
|
|
remote_dir: '{{ output_dir }}'
|
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
- file: path={{local_temp_dir}} state=directory
|
|
|
|
name: ensure temp dir exists
|
|
|
|
|
2018-01-19 01:42:20 +00:00
|
|
|
# file cannot do this properly, use command instead
|
2017-11-06 17:26:41 +00:00
|
|
|
- name: Create circular symbolic link
|
2018-01-19 01:42:20 +00:00
|
|
|
command: ln -s ../ circles
|
|
|
|
args:
|
|
|
|
chdir: '{{role_path}}/files/subdir/subdir1'
|
|
|
|
|
2017-08-15 16:41:16 +00:00
|
|
|
- name: Create remote unprivileged remote user
|
2017-08-01 05:07:22 +00:00
|
|
|
user:
|
|
|
|
name: '{{ remote_unprivileged_user }}'
|
|
|
|
register: user
|
|
|
|
|
|
|
|
- file:
|
|
|
|
path: "{{ user.home }}/.ssh"
|
|
|
|
owner: '{{ remote_unprivileged_user }}'
|
|
|
|
state: directory
|
|
|
|
mode: 0700
|
|
|
|
|
2017-08-15 16:41:16 +00:00
|
|
|
- name: Duplicate authorized_keys
|
2017-08-01 05:07:22 +00:00
|
|
|
copy:
|
|
|
|
src: $HOME/.ssh/authorized_keys
|
|
|
|
dest: '{{ user.home }}/.ssh/authorized_keys'
|
|
|
|
owner: '{{ remote_unprivileged_user }}'
|
|
|
|
mode: 0600
|
|
|
|
remote_src: yes
|
|
|
|
|
|
|
|
- file:
|
|
|
|
path: "{{ remote_dir }}"
|
|
|
|
state: directory
|
|
|
|
remote_user: '{{ remote_unprivileged_user }}'
|
|
|
|
|
|
|
|
# execute tests tasks using an unprivileged user, this is useful to avoid
|
|
|
|
# local/remote ambiguity when controller and managed hosts are identical.
|
|
|
|
- import_tasks: tests.yml
|
|
|
|
remote_user: '{{ remote_unprivileged_user }}'
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: Cleaning
|
|
|
|
file:
|
|
|
|
path: '{{ local_temp_dir }}'
|
|
|
|
state: absent
|
|
|
|
connection: local
|
|
|
|
|
2018-01-19 01:42:20 +00:00
|
|
|
- name: Remove circular symbolic link
|
|
|
|
file:
|
2017-11-06 17:26:41 +00:00
|
|
|
path: '{{ role_path }}/files/subdir/subdir1/circles'
|
2018-01-19 01:42:20 +00:00
|
|
|
state: absent
|
|
|
|
connection: local
|
|
|
|
|
2017-08-15 16:41:16 +00:00
|
|
|
- name: Remote unprivileged remote user
|
2017-08-01 05:07:22 +00:00
|
|
|
user:
|
|
|
|
name: '{{ remote_unprivileged_user }}'
|
|
|
|
state: absent
|
|
|
|
remove: yes
|