# Help for variable defination

**URL:** <https://forum.ansible.com/t/help-for-variable-defination/30930>\
**Category:** Ansible Project\
**Created:** [August 1, 2019, 12:24pm UTC](https://forum.ansible.com/t/help-for-variable-defination/30930 "2019-08-01T12:24:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [August 1, 2019, 12:24pm UTC](https://forum.ansible.com/t/help-for-variable-defination/30930/1 "2019-08-01T12:24:52Z")

</div>

HI Ansible Gurus,  
I have a specific snippet of code which i defined in default/main.yaml of a role xyz.

sw\_yum\_repositories:

- name: sw  
description: Dangerous sw  
file: sw-gw  
baseurl: “”  
enabled: no  
gpgcheck: “{{gpgcheckall | default(‘yes’)}}”  
gpgkey: “{{sw\_repository\_gpgkey | default(gpgkeys) | default(‘’)}}”

Now I override this variable sw\_yum\_repostories in my group\_vars/all.yml in inventory configuration files. Problem here is : i want to take default value of gpgkey attribute here from default/main.yml and other attributes i am overriding in group\_vars/all.yml . But when I try to define sw\_yum\_repostories without gpgkey attribute , it does not take default from default/main.yaml (it is part of source code) and whatever we define in group\_vars/all.yml(overidden ones) , it takes. Since gpgkey is something i want to take from default/main.yml(because it is less subject to change) rather than overriding and rest all attribute i want to override in group\_vars/all.yml, how can i achieve this ?  
Rahul

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [August 6, 2019, 7:52am UTC](https://forum.ansible.com/t/help-for-variable-defination/30930/2 "2019-08-06T07:52:07Z")

</div>

Any update on this? I need some solution for this ?

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [August 6, 2019, 11:51am UTC](https://forum.ansible.com/t/help-for-variable-defination/30930/3 "2019-08-06T11:51:34Z")

</div>

Hi Rahul,

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [August 7, 2019, 8:23am UTC](https://forum.ansible.com/t/help-for-variable-defination/30930/4 "2019-08-07T08:23:06Z")

</div>

Thanks much sebastian . I will try it out.

Rahul
