How can I pass registered output from a playbook to docker_compose task? In the playbook, I first create a temporary directory, and register the result:
- name: Create temporary deployment directory
tempfile:
state: directory
prefix: test.
register: tempdir
Later in the playbook, I have a docker_compose task like this:
- name: Create and start services
docker_compose:
project_name: test
project_src: "{{ tempdir.path }}"
This works so far that the compose file is run and the containers started. However, in the compose file itself, I need to reference the tempdir in the volumes section, to mount it into the container.
I tried this in the compose file, which obviously doesn't work:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- "{{ tempdir.path }}/certs/acme.json:/acme.json"
This isn't limited to passing the tempdir, as I might need other variables passed to the compose file too. E.g. from the inventory file.
NB. I'm fairly new to Ansible, so forgive me if I confuse any terms.