I'm trying to iteratively loop through a group_var that we have inside of our ansible environment and pull the salary value and use it inside of the command module. I have the following file inside of my ansible/groups_vars file -
people:
george:
lastname: smith
job:
title: associate
salary: 60
chris:
lastname: george
job:
title: senior
salary: 70
greg:
lastname: anderson
job:
title: director
salary: 95
This is the code I currently have:
- name: Run module check command against every docroot
command: 'drush --root=/var/www/html/wwwroot/{{item.0.salary}}/docroot en update'
with_subelements:
- "{{ people }}"
- job.salary
The error that I am seeing is:
FAILED! => {"msg": "the key salary should point to a list, got '60'"}
I put together this solution by looking at the following questions on here:
Ansible with_subelements
Ansible loop using multi-ter group_vars
Ansible with subelements referencing a dict
Trying to set the value to .0 or .1 seems to make it look for a dictionary, and setting it to [0] or [1] says:
{"msg": "could not find 'salary[1]' key in iterated item '{u'title': associate, u'salary': u'60'}"}
I feel like I'm really close to getting this working, but there's just a small piece that I am missing. How can I get it to iteratively loop through and pull that specific piece of information?