test: set TMPDIR in block of role invocation (#300)

Setting TMPDIR globally causes problems on some platforms.
Instead, set it at the `block` level and put the role
invocation inside the block.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
This commit is contained in:
Richard Megginson 2024-09-16 07:34:43 -06:00 committed by GitHub
parent d10f2ada11
commit 3331fa7b35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,6 @@
---
- name: Test quote with unsafe input
hosts: all
environment:
TMPDIR: "{{ __tmpdir }}"
vars:
__sshd_test_backup_files:
- /etc/ssh/sshd_config
@ -21,21 +19,19 @@
path: /tmp/BADFLAG
state: absent
- name: Assert TMPDIR is correctly set
ansible.builtin.assert:
that:
- __tmpdir != ''
- ansible_facts.env.TMPDIR == __tmpdir
- name: "Backup configuration files"
ansible.builtin.include_tasks: tasks/backup.yml
- name: Create BAD TMPDIR
ansible.builtin.file:
state: directory
path: "{{ ansible_facts.env.TMPDIR }}"
path: "{{ __tmpdir }}"
mode: '0755'
- name: Wrap this in a block to set environment
environment:
TMPDIR: "{{ __tmpdir }}"
block:
- name: Configure sshd with BAD config
ansible.builtin.include_role:
name: ansible-sshd
@ -64,7 +60,7 @@
- name: Remove BAD TMPDIR
ansible.builtin.file:
state: absent
path: "{{ ansible_facts.env.TMPDIR }}"
path: "{{ __tmpdir }}"
- name: "Restore configuration files"
ansible.builtin.include_tasks: tasks/restore.yml