Ansible: Share inventory variable between groups
You should be able to access the value of archive_name
through hostvars
:
- hosts: local
tasks:
# ... lots of local build steps here
- command: tar -czf {{ hostvars[groups['remote'][0]]['archive_name'] }} /build_dir
- hosts: remote
tasks:
- unarchive: src={{ hostvars[groups['remote'][0]]['archive_name'] }} dest=/deploy_dir