-1

I am using hostvars this way:

{{ hostvars['host']['something'] }}

and It's working fine. However, I want to use a variable name for hostname so I have done the following:

{{ hostvars[item]['something'] }}
with_items: groups['myhost']

and it's working but with a warning message:

[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full 
variable syntax ('{{groups["myhost"]}}').
This feature will be removed in a future release. Deprecation warnings can be disabled 
by setting deprecation_warnings=False in ansible.cfg.

is there a way I can achieve the same without the need to use deprecated stuff?

Mark Khateeb
  • 907
  • 3
  • 11
  • 26

1 Answers1

0

[Duplicate] The solution is:

{{ hostvars[item]['something'] }}
with_items: "{{ groups['myhost'] }}"
Mark Khateeb
  • 907
  • 3
  • 11
  • 26