Hello Everyone I have an issue with ansible roles running task with defined vars . . .

Kalesha Gagguturu:

---
# app agent installation
app_reinstall: false

# app agent configuration
app_agent_url: "******"
app_agent_key: "******"
app_agent_type: "****"
app_agent_location: "*******"
app_config_path: "/opt/app/agent/etc/app/configuration.yaml"
app_config_owner: "root"
app_config_group: "root"
app_config_mode: '0640'
app_config_content: |
  com.app.plugin.host:
    tags:
      - offering={{ app_tag_offering }}
      - category={{ app_tag_category }}
      - region={{ app_tag_region }}
      - datacenter={{ app_tag_datacenter }}
      - geo={{ app_tag_geo }}
      - availability-zone={{ app_tag_availability_zone }}
      - infrastructure={{ app_tag_infrastructure }}
      - service={{ app_tag_service }}
  com.app.plugin.generic.hardware:
    enabled: true
    availability-zone: {{ app_tag_availability_zone }}
...

Kalesha Gagguturu:
This is the content provided for me and I need to fix that to use in that task

Al West:
so it shows that app_tag_offering is not defined

Al West:
is it defined somewhere else?

Kalesha Gagguturu:
No

Al West:
so you see where you have used app_config_group: "root" - that is an assignment

Kalesha Gagguturu:
So that means we need to get all below details and define it in vars right

      - offering={{ app_tag_offering }}
      - category={{ app_tag_category }}
      - region={{ app_tag_region }}
      - datacenter={{ app_tag_datacenter }}
      - geo={{ app_tag_geo }}
      - availability-zone={{ app_tag_availability_zone }}
      - infrastructure={{ app_tag_infrastructure }}
      - service={{ app_tag_service }}

Al West:
but you have no assignment for app_tag_offering

Al West:
for example in your playbook you have fruit = apple and then in your vars you have apple = fruit

Al West:
you need to have something like app_tag_offering: plain

Kalesha Gagguturu:
So I need to have some value in vars file as
app_tag_offering=*****

Right

Al West:
not equals - use colon :

Kalesha Gagguturu:
Ya

Al West:
for vars

Kalesha Gagguturu:
so I should have all of them defined some where

Kalesha Gagguturu:
app_tag_*: *****

Al West:
yes - if the value is not defined in default vars it will look elsewhere like environment, command line etc.

Kalesha Gagguturu:
Ok, Default vars in roles/app/vars/main.yml right

Al West:
Yes. Refer to this:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#understanding-variable-precedence

Al West:
sorry it is roles/role/defaults/main.yml