TODO: Remember the stuff that drove me nuts as a noob...
These tactics shouldn't be employed in production.
- name: Shell with .bashrc
shell: |
source ~/.bashrc
custom_cmds...
Maintain a common download assets directory which can be used across multiple runs. This ensures that modules, such as 'get_url', are able to skip their action if an asset is already present. This conserves disk space, reduces bandwidth OPEX, reduces runtime, and mitigates unecessary internet traffic.
- name: "Create temp assets directory which will be utilized across multiple builds"
ansible.builtin.file:
path: /tmp/ansible_assets_dir
state: directory
mode: '0755'
register: temp_assets_dir
Note:
- This directory IS NOT to be cleaned up at the end of each run.
- This direcotry may be persisted outside of /tmp as needed.
- Some distributions only clear /tmp on boot. Configure as needed.
Maintain a discrete temporary directory for each run. The following prefixes the directory with both 'ansible' as well as a timestamp, ensuring ease of identification as needed.
- name: "Create temp directory for this build"
ansible.builtin.tempfile:
state: directory
prefix: "ansible_{{ now(utc=true,fmt='%Y-%m-%dT%H-%M-%SZ') }}_"
register: temp_dir
This directory may be cleaned up at the end of each run.