I am trying to deploy multiple instances of a service on a single host. The service has a config file, and in this config file, I'd like to include the index of the instance that it belongs to. For example:
# main.yml
- name: Configure each Instance
template: src=config dest=/usr/service/etc/config@{{item}}-{{count}}
with_items:
- "A"
- "B"
- "C"
# templates/config
id={{count}}
So ideally, I will end up with:
config@A-1
config@B-2
config@C-3
But I'm stuck on how I can get the "count" variable in there. I've looked at with_indexed_items
, but I'm not sure if that is the right way. I also looked at using a list of lists like this:
with_items:
- ["A", "1"]
- ["B", "2"]
- ["C", "3"]
But that doesn't feel like the most "Ansible" way to do this.