Skip to main content
put code into quotes.
Source Link
Bruce Becker
  • 3.7k
  • 4
  • 19
  • 41

I have a hardcoded hostvars line, like so:

node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }}node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }}

I have a set_factset_fact variable from a previous play that I'd like to expand in the host section of the hostvars declaration, instead of the IP address. Can hostvars take expansion inside those brackets and single quotes?

Thanks.

I have a hardcoded hostvars line, like so:

node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }}

I have a set_fact variable from a previous play that I'd like to expand in the host section of the hostvars declaration, instead of the IP address. Can hostvars take expansion inside those brackets and single quotes?

Thanks.

I have a hardcoded hostvars line, like so:

node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }}

I have a set_fact variable from a previous play that I'd like to expand in the host section of the hostvars declaration, instead of the IP address. Can hostvars take expansion inside those brackets and single quotes?

Thanks.

Source Link

Ansible - Variable expansion inside hostvars declaration?

I have a hardcoded hostvars line, like so:

node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }}

I have a set_fact variable from a previous play that I'd like to expand in the host section of the hostvars declaration, instead of the IP address. Can hostvars take expansion inside those brackets and single quotes?

Thanks.