Re: [ansible-project] Help for variable defination

2019-08-07 Thread Rahul Kumar
Thanks much sebastian . I will try it out.

Rahul

On Tue, 6 Aug 2019 at 17:21, Sebastian Meyer  wrote:

> Hi Rahul,
>
> On 01.08.19 14:24, Rahul Kumar wrote:
> > 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 .
>
>
> https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-hash-behaviour
>
> This could work for you. Otherwise you might want to look at setting a
> different variable and merge them using set_fact and the combine jinja
> filter.
>
> Sebastian
>
> --
> Sebastian Meyer
> Linux Consultant & Trainer
> Mail: me...@b1-systems.de
>
> B1 Systems GmbH
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
>
>
> -- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
>  https://openstack-tage.de (Code DOST-B1) 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c055b047-81ad-001f-ec17-ca55df3dde9c%40b1-systems.de
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGH8rEzs8e%3D_tFSYBjLzkuUVhe8r7vkNh7KeZRFSd86GDaRrdA%40mail.gmail.com.


Re: [ansible-project] Help for variable defination

2019-08-06 Thread Sebastian Meyer
Hi Rahul,

On 01.08.19 14:24, Rahul Kumar wrote:
> 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 .

https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-hash-behaviour

This could work for you. Otherwise you might want to look at setting a
different variable and merge them using set_fact and the combine jinja
filter.

Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


-- Deutsche OpenStack Tage 2019 -- 10% Rabatt auf den Ticketpreis 
 https://openstack-tage.de (Code DOST-B1) 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c055b047-81ad-001f-ec17-ca55df3dde9c%40b1-systems.de.


[ansible-project] Help for variable defination

2019-08-01 Thread Rahul Kumar
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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGH8rEw2z3cJh6WAOMq_a7%2BKy5uGzA-6j22MG5B1QXTJOBdGFA%40mail.gmail.com.