Diversify the name of temporary directory depending on the task
Summary
When running at the same time playbooks restore.yml
and backup.yml
they both use the same temporary directory. When one of that playbooks ends first and deletes that temporary directory. That causes fail of second playbook execution.
Steps to reproduce
Run both restore and backup at the same time at one host with default variables.
Expected behavior
Both playbooks execute successfully.
Actual behavior
One of playbooks fails due to no existing folder.
Relevant logs and/or screenshots
TASK [elasticsearch : backup index log-2018.10.23-mapping] *********************
Monday 29 October 2018 14:51:40 +0000 (0:00:00.217) 0:30:07.616 ********
fatal: [localhost]: FAILED! => {"changed": true, "msg": "Mon, 29 Oct 2018 14:51:42 GMT | starting dump\nMon, 29 Oct 2018 14:51:42 GMT | got 1 objects from source elasticsearch (offset: 0)\nMon, 29 Oct 2018 14:51:42 GMT | sent 1 objects to destination file, wrote 1\nMon, 29 Oct 2018 14:51:42 GMT | got 0 objects from source elasticsearch (offset: 1)\nevents.js:183\n throw er; // Unhandled 'error' event\n ^\n\nError: EACCES: permission denied, open '/var/lib/citask/schedules/openstack-backup/elasticsearch_backup_restore_tmp/f2d32207-8d99-59da-b7c5-0a2b8d5a86a7'\n", "status": 1}
Possible fixes
Name of temporary folder defined by elasticsearch_temporary_directory
variable may contain UUID used for naming backups before or after archiving it.
(https://projects.task.gda.pl/ansible-roles/elasticsearch/blob/master/defaults/main.yml#L3)