mdklatt.tmpdir
Temporary Directory ######
This Ansible role
will create a temporary working directory that will be automatically deleted at the end of the play. Only one directory is created per play, no matter how many times this role is included.
You can also find this role on Ansible Galaxy
.
============ Requirements ============
The machine you are targeting must have the mktemp
command installed.
============== Role Variables ==============
tmpdir_root
: The root path where the temporary directory will be created (it must exist). It defaults to the system's temporary directory.tmpdir_template
: This is used to create the directory name and defaults totmp.XXXXXX
.tmpdir_path
: The path to the created temporary directory, which is established when the play runs.tmpdir_force
: This determines whether the temporary directory can be removed by a privileged user. It defaults to false.
The root
and template
variables should only be set in the playbook. After the temporary directory is created, changing these variables won't have any effect. Other roles using this one should not rely on modifying these values for their own purposes.
If you set force
to true, the cleanup handler can remove any files created by a privileged user.
================ Example Playbook ================
- hosts: all
roles:
- name: tmpdir
tmpdir_root: /tmp
tmpdir_template: tmp.XXXXXXXX
tasks:
- name: Download temporary directory source
unarchive:
src: https://github.com/mdklatt/ansible-tmpdir-role/archive/master.zip
dest: "{{ tmpdir_path }}"
copy: false
================= Molecule Workflow =================
Use the Molecule
framework for cross-platform testing:
$ python -m molecule --all --parallel test
.. |travis.png| image:: https://travis-ci.org/mdklatt/ansible-tmpdir-role.svg?branch=main
:alt: Travis CI build status
:target: travis
_
.. _travis: https://travis-ci.org/mdklatt/ansible-tmpdir-role
.. _Ansible role: http://docs.ansible.com/ansible/playbooks_roles.html#roles
.. _Ansible Galaxy: https://galaxy.ansible.com/mdklatt/tmpdir
ansible-galaxy install mdklatt.tmpdir