To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1404913541-sup-3375%40al.wesleyan.edu.
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Correct.Tags in playbooks apply tags to tasks.--tags means "run the things that are so tagged"--skip-tags means the opposite
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b2d74d00-f73f-42c9-be26-72ecd8a7c2ed%40googlegroups.com.
"Now the other question: would it be reasonable to ask for such feature then? "
It would not :)I think it makes much more sense to explicitly tag things.
For instance, think of flickr.com and I tag all pictures in an album "vacation", I don't have the ability to take another album and tag pictures "not vacation" in such a way that the vacation tag doesn't pick them up.Being able to say "don't run these tags" if of course what --skip-tags does, and we can do that.
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f235c0cf-9103-41e5-a4b2-612223cd1560%40googlegroups.com.
- { role: A, skip-tags: [t1, t2] }
whould be very useful in case of playbook with many roles having same tags thus --skip-tags is not an option in case one wants to skip tags in couple of roles only.
Any plans to support this?
./run_playbook.py site.yml
ansible-playbook -i hosts site.yml --skip-tags='debug'
tasks:
- name: Show vars
debug: msg={{item.ansible_facts}}
with_items: some_loaded_vars.results
tags: debug
when: debug|default(false)
ansible-playbook site.yml -e '{"debug":true}'
On 03.02.2019 01:53, Igor Cicimov wrote:
> Kai, why would I use vars when I already have tags on my tasks which
> purpose, and only purpose, is filtering during execution?
Filtering is done on the command line with --tags not inside a playbook
or task file.
- roles:
- role1 - role2 - role3
If you need any other functionality, variables is the way to go.
> Also as I said back in 2015
> https://groups.google.com/d/msg/ansible-project/WimzDEJLHJc/9U10Yjb4CQAJ
> it
> is hard to retrofit variables into hundreds of playbooks you have
> written
> with tags expecting they will serve the purpose they exist for, *which
> is
> filtering*.
They do, the filtering is done on the command line.
Tags on a role in a playbook is adding the tags to all the task in the
role.
So it pretty uniform, tags in in task files and playbooks is adding that
tag to the task.
Filtering is done at run time on the command line.
> From where I stand, the "tags" option that we can pass to the role like
> this:
>
> - roles:
> - { name: role1 tags: ["tag1","tag2"] } <== this *IS/SHOULD BE*
> equivalent to a command line
Why should it, in my opinion this will make it pretty confusing for when
tags add a tag and when it's filtering on tags.
> is pretty much useless since instead filtering the role's tasks based
> on
> that "tags" list it adds those tags to each of them. Really not sure
> how is
> this helping me in any way and what would be the use case or advantage
> I
> get from doing this? I mean if I wanted those tags in a role I would
> have
> included them in its tasks already ... or am I missing something?
The functionality is that if you want to run a few of the role(s) in a
playbook, add a tag to the role and filter the tag on the command line.
I use this feature a lot, a playbook have have tens of roles and I just
want to run one or two of them, so changing that will destroy my and
everyone else's use of tags.
If you download a role from Galaxy you don't want to change the tags in
the role because that makes it very hard to download newer version of
that role.
But you can at least add your own tags on the role so you can filter to
run or not run the role when the playbook is running.
> So to conclude, when I call a role with *tags* I expect those and only
> those tags to be in effect during role's execution.
But I don't, and it's not feature I need since I use variables for that.
> Similarly I would
> expect to use *skip-tags* for tags I do not want executed during run
> time.
> Instead of that you are telling me to use vars when I already have tags
> that should serve the purpose.
The problem here is if you have 20 roles where all roles have uniq tag
and you only want to run one of them, adding 19 skiped tags instead of 1
include tag is not very practical.
> Not sure why such a resistance towards a feature that is very logical
> to
> have and makes much more sense than what it is atm.
It might be logical for you but that doesn't mean it is logical for
everyone else.
There is no resistance of new feature, only removing the one that's
there.
In Ansible they have a rule to not break/change feature that people use
unless it's a bug, this one is not a bug as it has function like this
for years and people are using the feature. (Like all rules, there are
exception but I hardly think this is one of them.)
So changing how tags works on role is probably not going to happen, but
an alternative could be to add new keyword to something like a filter
tag and a add tag.
You are free to add a proposal at https://github.com/ansible/proposals
and maybe someone have already done that for all i know.
--
Kai Stian Olstad
On 04.02.2019 04:10, Igor Cicimov wrote:
> On Monday, February 4, 2019 at 12:10:51 AM UTC+11, Kai Stian Olstad
> wrote:
Probably pretty useless to answer but anyway.
>>
>> On 03.02.2019 01:53, Igor Cicimov wrote:
>> > Kai, why would I use vars when I already have tags on my tasks which
>> > purpose, and only purpose, is filtering during execution?
>>
>> Filtering is done on the command line with --tags not inside a
>> playbook
>> or task file.
>>
>
> That's correct ... and have you tried doing so? In the below example:
>
> - roles:
> - role1
> - role2
> - role3
>
> where all 3 roles have the same tags, lets say "instal" and
> "configure",
> how are you going to filter the "install" tag for the role1 only?
You can't without having unique tag.
I understand what you are looking for, I just say that is not possible
with Ansible at the moment and if you need that kind of functionality
use variables instead.
> If you need any other functionality, variables is the way to go.
>>
>
> Yeah like in the example you gave above:
>
> ---
> - include_tasks: install.yml
> when: test_install | default(true) == true
>
> - include_tasks: configure.yml
> when: test_configure | default(true) == true
>
> so you end up with separate file for each tag you have, good luck with
> that.
I don't know why I need good luck with that, been doing it for years and
it just work.
> How about if I
> have 90 tasks in a role and want to exclude 45? Much more difficult
> isn't
> it?
At the moment I solve that by have roles that just do a very specific so
I don't have to just a few tasks in a role.
But in some of them I do i tend to stick them in a file and use
include_tasks with a when on it.
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/36b5a50a-7aff-4659-9ab9-c881baa74ee1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.