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

Kalesha Gagguturu:
I am defining in roles/app/vars/main.yml file

Kalesha Gagguturu:
The task is

 blockinfile:
    create: true
    state: present
    path: '{{ app_config_path }}'
    owner: '{{ app_config_owner }}'
    group: '{{ app_config_group }}'
    mode: '{{ app_config_mode }}'
    insertbefore: BOF
    marker: "# {mark} Infrastructure config block"
    marker_begin: "Start"
    marker_end: "End"
    block: "{{ app_config_content }}"
  notify: app_agent_restart

Al West:
I saw the task in your post, show the vars.

Kalesha Gagguturu:
ok

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_*: *****