You've described it good enough, I'm saying it's meant to be that way. I have also mentioned above about the protections in place on "vars", but because "defaults" are inventory scope (so inventory can override them) they do not apply to defaults.
Namespace your variables by prefixing them with the role name will make this basically go away. On Fri, Apr 4, 2014 at 12:28 PM, Marko_Lisica <[email protected]>wrote: > Hello, > > I guess I havent described good enough. variables get inherited from other > roles if they are stored in defaults. > And if I run playbook with tags, I dont want variables to be inherited > from the role that is not called with tags in the particular play. > > Is that current behaviour? Or vars are inherited from every role in a play > regarding if they are actually called with a tag in specific play or not. > > > On Fri, Apr 4, 2014 at 5:21 PM, Michael DeHaan <[email protected]>wrote: > >> Yes. >> >> Tags apply only to the tasks therein, not the variables themselves. >> >> >> On Fri, Apr 4, 2014 at 11:18 AM, Marko_Lisica <[email protected]>wrote: >> >>> Thing is that I wanted to point out if I tag my roles, and run a play, >>> is it intended to inherit vars from a role that is not in that particular >>> play although it exists in playbook, but it is excluded in particular run >>> because of tags. >>> >>> >>> On Fri, Apr 4, 2014 at 5:10 PM, Michael DeHaan <[email protected]>wrote: >>> >>>> Defaults load into inventory scope. >>>> >>>> What I said applies to things in vars/ >>>> >>>> >>>> On Fri, Apr 4, 2014 at 3:11 AM, Marko_Lisica <[email protected]>wrote: >>>> >>>>> Hi, >>>>> >>>>> That is 100% clear. But in this case one role does not have its own >>>>> defaults and inherits defaults from the last role in a list regardles if >>>>> that role is played or not. >>>>> >>>>> >>>>> On Fri, Apr 4, 2014 at 12:16 AM, Michael DeHaan >>>>> <[email protected]>wrote: >>>>> >>>>>> It's entirely intended. For instance, you might have a role that >>>>>> applies a particular configuration to machines that live in a particular >>>>>> datacenter, and one of the things that sets might be the port to use for >>>>>> the database >>>>>> server. That port variable would then be available to other roles. >>>>>> >>>>>> While this sounds scary at first, Ansible contains safeguards to make >>>>>> sure the variables used in one role are absolutely used there and not >>>>>> clobbered by another. Thus they have guaranteed scope to that role. >>>>>> >>>>>> As such, if you define a variable "port" in two places, each role is >>>>>> guaranteed to be able to read the local value. >>>>>> >>>>>> >>>>>> On Thu, Apr 3, 2014 at 10:09 AM, Marko Lisica <[email protected] >>>>>> > wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> I stumbled onto little mind game with ansible today : D . >>>>>>> >>>>>>> I have three roles that are tagged. >>>>>>> >>>>>>> - hosts: vagrant >>>>>>>> sudo: yes >>>>>>>> roles: >>>>>>>> - {role: ansible_users, tags: users} >>>>>>>> - {role: ansible_nginx, tags: nginx} >>>>>>>> - {role: ansible_mysql, tags: mysql} >>>>>>>> >>>>>>> >>>>>>> I have defaults/main.yml for "ansible_users" and "ansible_mysql" in >>>>>>> their respective places. >>>>>>> >>>>>>> This is "ansible_users" defaults: >>>>>>> >>>>>>> --- >>>>>>>> users: >>>>>>>> - user: detlic >>>>>>>> webdir: >>>>>>>> - woodpecker >>>>>>>> - aligator >>>>>>>> - user: keder >>>>>>>> webdir: [] >>>>>>>> >>>>>>> >>>>>>> This is "ansible_mysql" defaults: >>>>>>> >>>>>>> --- >>>>>>>> users: >>>>>>>> - user: detlic >>>>>>>> db: >>>>>>>> - aligatordb >>>>>>>> - woodpeckerdb >>>>>>>> - user: jazavac >>>>>>>> db: >>>>>>>> - badgerdb >>>>>>>> - ddaybdb >>>>>>>> >>>>>>> >>>>>>> I have left NGINX role without "defaults". How I understand things >>>>>>> is that NGINX will inherit "defaults" vars from other roles and use them >>>>>>> where it can. But in this case {{ VARS }} are named the same in both >>>>>>> USER >>>>>>> and MYSQL roles. >>>>>>> >>>>>>> NGINX role is before MYSQL from whoom it should inherit vars? In my >>>>>>> test case it inherits it from the LAST role in the list. So in this >>>>>>> case it >>>>>>> is MYSQL. If I remove MYSQL role from a list then everything is fine. >>>>>>> >>>>>>> Another thing is if I leave MYSQL role present BUT use TAGS and play >>>>>>> roles with jsut USERS and NGINX tags, still NGINX inherits "defaults" >>>>>>> from >>>>>>> MYSQL. >>>>>>> >>>>>>> Can someone comment on this. >>>>>>> >>>>>>> -- >>>>>>> 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 [email protected]. >>>>>>> To post to this group, send email to >>>>>>> [email protected]. >>>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/ansible-project/eb9bf810-d04e-4998-86e4-72e0ab8aa791%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/eb9bf810-d04e-4998-86e4-72e0ab8aa791%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to a topic in >>>>>> the Google Groups "Ansible Project" group. >>>>>> To unsubscribe from this topic, visit >>>>>> https://groups.google.com/d/topic/ansible-project/y_Gucqc_3sE/unsubscribe >>>>>> . >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> [email protected]. >>>>>> >>>>>> To post to this group, send email to [email protected] >>>>>> . >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/ansible-project/CAEVJ8QPg4RQo6Ae-K0pLUAkyA6J2W7R53-nxGNmZPR%3DGKKM7iA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEVJ8QPg4RQo6Ae-K0pLUAkyA6J2W7R53-nxGNmZPR%3DGKKM7iA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/ansible-project/CABqYKhB9bpMmDOz7QDhCscrsY%3DWAdvpAor65pBtRpXh5GToqPQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CABqYKhB9bpMmDOz7QDhCscrsY%3DWAdvpAor65pBtRpXh5GToqPQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Ansible Project" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/ansible-project/y_Gucqc_3sE/unsubscribe >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> To post to this group, send email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/ansible-project/CAEVJ8QOJbjo8qDz9e%2ByfrJYD28TcJmgkczho9By%2BnKc%3Dhd25%2BA%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEVJ8QOJbjo8qDz9e%2ByfrJYD28TcJmgkczho9By%2BnKc%3Dhd25%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/CABqYKhAJ1HQ72N53Bf-UL1%2BHaXtbcrHaTrMz0KGqu9uAk2-81A%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CABqYKhAJ1HQ72N53Bf-UL1%2BHaXtbcrHaTrMz0KGqu9uAk2-81A%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Ansible Project" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/ansible-project/y_Gucqc_3sE/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/CAEVJ8QNYTFfpEuqX7uHP-S_BmAOMSzm25v7bmTWf6Bo4pNtjuQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEVJ8QNYTFfpEuqX7uHP-S_BmAOMSzm25v7bmTWf6Bo4pNtjuQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CABqYKhBTRmMspB_nVsOXNLYfKC8nmcz_68kS4MpoCvzEfMoOZQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CABqYKhBTRmMspB_nVsOXNLYfKC8nmcz_68kS4MpoCvzEfMoOZQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEVJ8QO2kqn15QDVL50FHo8AMGGfih_NSSSDBq7QVPWq%3DdHpYQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
