What you say is a "well understood ansible convention" I am having trouble
processing.

I read most of your posts and think you are in general not getting the Zen
of Ansible too much.

Keep things simple.

Don't think about trying to read what some default value is.   Just use the
value that makes it through, knowing that the right value made it through.

The "skip_tasks" stuff, and other hacks should be shunned.

Once you get the bare minimum to automate application X, stop.

It's not supposed to be a super-elegant software construct, or even a
programming language.  It's a language for getting things done.








On Tue, May 27, 2014 at 9:45 AM, Brice Burgess <[email protected]> wrote:

> I often need to access the default variables of another role. Currently
> I'm doing this via role dependencies, and passing a special variable to
> skip running a roles tasks. E.g.
>
> ```
>
> :: my_role/meta/main.yml ::
> dependencies:
>   - { role: other_role, skip_tasks: True }
>
>
> :: other_role/tasks/tasks.yml ::
> - { include: prepare.yml, tags: ['prepare'], when: skip_tasks is not
> defined or not skip_tasks }
>
> ```
>
> This is nice because it accomplishes loading variables from other_role
> (default/main.yml, vars/main.yml) and is a well understood ansible
> convention... although it adds additional variable complexity (skip_tasks)
> and verbosity to the playbook output (all the skipped tasks are reported).
> As an alternative I am thinking about explicitly included the desired vars
> (if they are not already available). E.g.
>
> ```
>
> :: my_role/tasks/main.yml ::
>
> - name: gather variables
>   include_vars: "'/path/to/other_role/defaults/main.yml"
>   when: needed_var_from_other_role is not defined
>
> ```
>
> Is this a recommended approach?
>
> Alternatively I could probably stick all shared variables in a taskless
> common role that's depended upon -- although prefer the naturality of
> keeping the vars in their related role.
>
> Thanks for your insight!
>
> ~ Brice
>
>
>
> --
> 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/adb5acd6-9221-42c5-b0cd-313edafa3e38%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/adb5acd6-9221-42c5-b0cd-313edafa3e38%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 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/CA%2BnsWgx9YcYuUyUs0dqPGUcb4QKspANieMsAMDBQBGO%3DDUxHKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to