0

i have in the inventory host with own variables:

children:     
    webserver:
      vars:        
      hosts:
        web01.local:
          function: live
          location: lca         
        web02.local:
          function: test
          location: lcb

now i would like to create a playbook, which installs the snmpd service on each of the hosts (all) and stores the value "location" from the inventory.

How can I access this variable "location" in the playbook?

Kr3el
  • 3
  • 1

1 Answers1

1

If your playbook is targeting the remote hosts, you can just refer to the location variable:

- hosts: webserver
  tasks:
    - debug:
        msg: "value of location: {{ location }}"
larsks
  • 277,717
  • 41
  • 399
  • 399