Hello, is it possible to do the following
- hosts: localhost
gather_facts: False
tasks:
Hello, is it possible to do the following
tasks:
Probably something like
hostvars[groups['webservers']|first].new_ips
You mean hostvars[groups[‘localhost’]|first.new_ips
Doesn’t work!
{{hostvars[groups[‘localhost’].new_ips.results.stdout}}
Gives the following error: One or more undefined variables: ‘dict object’ has no attribute ‘localhost’
You know what- I answered your title, not your question. If you don't
want to have to try and persist things between plays, you might have
more luck with something like this:
- hosts: myhosts
tasks:
- shell: echo things
local_action: true
register: new_ips
- shell: echo other things {{new_ips}}
but there's nothing in your example that seems to necessitate anything
that you're doing.
haha…okay! I did not want to post my whole playbook as it might get confusing. I really do appreciate your help though. Here is a sizeable chunk of the playbook which might make things easy (or difficult) to understand
#$ cat khan.yml