Skip to content

Instantly share code, notes, and snippets.

@pgilad
Created October 27, 2015 15:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pgilad/9c5565f22da87cfb913e to your computer and use it in GitHub Desktop.
Save pgilad/9c5565f22da87cfb913e to your computer and use it in GitHub Desktop.
Create a temp dir cross-platform in ansible
- name: create a local temp directory
local_action:
module: command mktemp -d "{{ lookup('env', 'TMPDIR') | default('/tmp/') }}ansible.XXXX"
register: mktemp_output
@brianretford
Copy link

If you switch 'default('/tmp', true)' you can get around machines with empty TMPDIRs

@santoshkkhade
Copy link

fatal: [sl73tapwbq001.visa.com]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/test/ansible/logs/{'stderr_lines': [], u'changed': True, u'end': u'2017-10-03 09:19:51.153513', 'failed': False, u'stdout': u'user.32Ui', u'cmd': [u'mktemp', u'-d', u'user.XXXX'], u'rc': 0, u'start': u'2017-10-03 09:19:51.149430', u'stderr': u'', u'delta': u'0:00:00.004083', 'stdout_lines': [u'user.32Ui']}): File name too long"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment