I have a large Ansible playbook where Docker images are built when running it. I am using an increasing number as the tag to version them. Currently, I have to specify this in e
If the tag/version you are using is applicable to all hosts, then using group_vars/all is a viable option.
If the revision numbers are specific to each host entries in a host_vars/host_name file might be better.
If you want to read and initial var and then increment it after each play that becomes a bit more difficult to persist that information across plays (or each -hosts as you say) in the playbook. For example if you were looking to deploy N docker instances you might do some dynamic inventory magic like this:
- hosts: localhost
tasks:
- add_host: name=docker_{{item}} groups="dockers,other" tag={{item}}
with_sequence: start={{ext_def_start}} count={{ext_def_num}}
- hosts: docker_*
tasks:
- debug: var=tag