Re: [ansible-project] Tags as variable inside of playbook

2023-06-14 Thread Brian Coca
Use the never tag: tags: never, mytag This ensures the task is never selected UNLESS you specifically target a defined tag. -- -- Brian Coca -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop

Re: [ansible-project] Tags as variable inside of playbook

2023-06-14 Thread Brian Lamb
A Magic var has been added, you can use ansible_run_tags now. https://github.com/ansible/ansible/blob/stable-2.5/changelogs/CHANGELOG-v2.5.rst#minor-changes-4 On Wednesday, June 14, 2023 at 10:54:35 AM UTC-7 Brian Lamb wrote: > This looked promising, except that cli is not available on my

Re: [ansible-project] Tags as variable inside of playbook

2023-06-14 Thread Brian Lamb
This looked promising, except that cli is not available on my ansible v 2.14.2 using python 3.11.2 `Error was a , original message: cannot import name ''cli'' from ''__main__'' (/usr/bin/ansible-playbook)'` On Tuesday, March 15, 2016 at 12:40:13 PM UTC-7 Mike Biancaniello wrote: > It sounds

Re: [ansible-project] Tags or Variables, not sure which way to go

2020-08-17 Thread John Petro
Thanks for the response. I did see that this morning, but hadn't had a chance to test it out yet. I"ll give that option a shot and see if it's better than the variable method I ended up writing. --John On Mon, Aug 17, 2020 at 1:18 PM alicia wrote: > Hi John, > > The opposite of “- -tags

Re: [ansible-project] Tags or Variables, not sure which way to go

2020-08-17 Thread alicia
Hi John, The opposite of “- -tags my_tag” is “—skip-tags my_tag” - see the updated documentation on tags at https://docs.ansible.com/ansible/devel/user_guide/playbooks_tags.html . You would, of course, need to add tags to

[ansible-project] Tags or Variables, not sure which way to go

2020-08-16 Thread John Petro
So I am having an issue about not knowing what the best thing to do is. Here's what I am trying to accomplish... I have the following sanitized tasks: - name: Set authorized key ( prod) authorized_key: user: ansible state: present key: "{{ lookup('file', 'ssh public key file) }}"

Re: [ansible-project] Tags in loop

2019-01-29 Thread Karl Auer
Great! Then I just told you how to do it. vars: mytags: fred: frederick rod: roderick - module_whatever: [...] tags: "{{ mytags }}" [...] Or if you have the IDs of the resources you want to tag, use the ec2_tag module. Regards, K. On Wed, Jan 30, 2019 at 10:27

Re: [ansible-project] Tags in loop

2019-01-29 Thread Rafael Tomelin
Hi, This tag in ansible. I need set key and value (- key: value), but in variable. On Tue, Jan 29, 2019 at 7:36 PM Karl Auer wrote: > > What kind of tag? Do you mean an ansible tag, or a tag for e.g. Amazon > resources? > > If you mean Ansible tags, I do not know. > > If you mean AWS tags,

Re: [ansible-project] Tags in loop

2019-01-29 Thread Karl Auer
What kind of tag? Do you mean an ansible tag, or a tag for e.g. Amazon resources? If you mean Ansible tags, I do not know. If you mean AWS tags, most resource modules provide a "tags" attribute, if the resource supports tags. Some resources (generally those with IDs) can be tagged using the

[ansible-project] Tags in loop

2019-01-29 Thread Rafael Tomelin
Hi dear, I need create tag in my role, this example: vars/main.yml name_variable: tags: key1: value1 key2: value2 in tasks taks/main.yml - name: name my task user: name tags: tags from vars how can create this tags? -- Atenciosamente, Rafael Tomelin Tel.:

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-09-22 Thread Michael Ströder
On 8/24/18 4:31 PM, Kai Stian Olstad wrote: > You can also wrap the include_tasks in a block, and set the tags on the block. > > - block: > - name: My Task > include_tasks: "mytask.{{ansible_osfamily}}.yml" > tags: > - mytask-only > - always Given the volatility of

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-27 Thread Brian Coca
We reverted the deprecation on include, the feedback did make it clear we had made a mistake at the time. We have revised our deprecation policy to trail the stable substitute vs always being immediate. -- -- Brian Coca -- You received this message because you are subscribed to the

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-27 Thread Kai Stian Olstad
On Monday, 27 August 2018 16.59.03 CEST Brian Coca wrote: > - `include:` still exists, yes we are planning to eventually deprecate as > it has mixed static/dynamic behaviour and it is not easy to know which you > will get > > - `include_role`/`include_tasks` were created to represent the

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-27 Thread Brian Coca
A few of things: - `include:` still exists, yes we are planning to eventually deprecate as it has mixed static/dynamic behaviour and it is not easy to know which you will get - `include_role`/`include_tasks` were created to represent the 'dynamic' parts of the existing `include`, but they

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-25 Thread stan . varlamov
This is an interesting post that touches upon the topic: https://medium.com/opsops/ansible-2-5-delegate-to-and-include-role-20cd7e67008e The way I look at it, Ansible team has chosen a path of keeping the product competitive vs. maintaining backward compatibility at all costs. The Best

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-24 Thread Frank Thommen
Thanks a lot Kai, On 08/24/2018 04:31 PM, Kai Stian Olstad wrote: On Friday, 24 August 2018 15.47.39 CEST Frank Thommen wrote: since "recently" (we realized just now), tags applied in role's main.yml task, like: /role/myrole/tasks/main.yml: - name: My Task include_tasks:

Re: [ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-24 Thread Kai Stian Olstad
On Friday, 24 August 2018 15.47.39 CEST Frank Thommen wrote: > since "recently" (we realized just now), tags applied in role's main.yml > task, like: > > /role/myrole/tasks/main.yml: > > - name: My Task >include_tasks: "mytask.{{ansible_osfamily}}.yml" >tags: > - mytask-only >

[ansible-project] Tags not propagated to dynamically included tasks: Workaround?

2018-08-24 Thread Frank Thommen
Dear all, since "recently" (we realized just now), tags applied in role's main.yml task, like: /role/myrole/tasks/main.yml: - name: My Task include_tasks: "mytask.{{ansible_osfamily}}.yml" tags: - mytask-only - always are not propagated to the included task any more. It still

[ansible-project] tags within included_tasks do not work?

2017-11-02 Thread coolcps
In a playbook I have a file of tasks included, like so: - include_tasks: uplinks.yml And within that task file I have a task: - name: configure hosts ios_config: commands: - ip host {{ item['name'] }} {{ item['port'] }} {{ interfaces['mgmt']['ip'] }} with_items: "{{ host_entries

[ansible-project] --tags not propagating thru a play include

2017-08-31 Thread Barry Kaplan
I have a playbook that includes lots of other playbooks, eg # site.yml - include: mesos-master.yml - include: mesos-slave.yml Inside mesos-master.yml for example, I have play that looks like - name: Configure logging hosts: mesos_master become: yes tags: [logging] roles: - role:

Re: [ansible-project] Tags as variable inside of playbook

2016-03-15 Thread Mike Biancaniello
It sounds like you want to instruct a task to execute ONLY if a tag is present (skip if tag not set). I've seen that request before, but no idea if it may or may not be implemented. I wonder if a vars_plugin or lookup_plugin might work. would this work? # file ./lookup_plugins/get_tags.py

Re: [ansible-project] Tags as variable inside of playbook

2016-03-15 Thread Branko Majic
Thanks for the input, but that is something that would solve my requirement only partially. What I wanted to do was more along the lines of (as someone has already pointed out, tags do not seem to be exposed in a run): - name: Run this only and only if the tag was defined debug: msg="I am

Re: [ansible-project] Tags as variable inside of playbook

2016-03-15 Thread Jean-Yves LENHOF
If I understand correctly what you want... ansible-playbook myplaybook.yml --tags=myspecialtag is what you're looking for... A tag can be use in more than one task... The doc : http://docs.ansible.com/ansible/playbooks_tags.html Regards, Le 2016-03-15 13:08, Branko Majic a écrit : Hello

[ansible-project] Tags as variable inside of playbook

2016-03-15 Thread Branko Majic
Hello folks, Is it possible to use tags as a variable inside of playbook? Specifically, I would like to have a condition to execute certain task only if a tag has been defined. I am aware this can be done with an --extra-vars option + checking for variable instead, but I wanted to see if I

Re: [ansible-project] tags with roles

2015-07-23 Thread Vladimir Ondrus
Hi Brain, thanks for the explanation. Here is similar problem we have: We have a download role which should download something from given location(web, maven, local). So when location is maven, I dont want to execute http steps. But when when statement is after include this means that all tasks

Re: [ansible-project] tags with roles

2015-07-23 Thread Brian Coca
the when will be applied to each task, so they will be skipped -- Brian Coca -- 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

Re: [ansible-project] tags with roles

2015-07-23 Thread Vladimir Ondrus
this is current state: when you want to implement this if(x=true) task1 task2 task3 task4 task5 if(y=true) task6 task7 you should write when to each task: task1 when x task2 when x task3 when x task4 when x task5 when x task6 when y task7 when y but when there would be something

Re: [ansible-project] tags with roles

2015-07-23 Thread Brian Coca
you can write the when in the include or in 2.0 use blocks On Thu, Jul 23, 2015 at 8:13 AM, Vladimir Ondrus vladimir.ond...@gmail.com wrote: this is current state: when you want to implement this if(x=true) task1 task2 task3 task4 task5 if(y=true) task6 task7 you

[ansible-project] tags with roles

2015-07-16 Thread Vladimir Ondrus
Hi All, I want to use tags inside the roles, here is my usecase: I want to execute tasks marked with from testrole: [root@wildfly ~/ansible]$ cat test.yml --- - hosts: local roles: - {role: testrole, tags: ['']} here is the role: [root@wildfly ~/ansible]$ cat

Re: [ansible-project] tags with roles

2015-07-16 Thread Brian Coca
Hi Vlado, I think you are misunderstanding the feature. There is no sub -election with tags on role definition, when you: - {role: testrole, tags: ['']} What you are doing is tagging all tasks in testrole with '' on top of existing tags. So it would look like this once imported: -

Re: [ansible-project] --tags tag1 AND tag2, possible?

2015-06-05 Thread nusenu
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Brian Coca: I was not thinking of a specific ticket, but there should be many instances of this being requested via the maliing lists and IRC and even as comments in other tag related tickets. ok sounds like one should create an issue for it:

Re: [ansible-project] --tags tag1 AND tag2, possible?

2015-06-05 Thread Brian Coca
I was not thinking of a specific ticket, but there should be many instances of this being requested via the maliing lists and IRC and even as comments in other tag related tickets. -- Brian Coca -- You received this message because you are subscribed to the Google Groups Ansible Project

[ansible-project] --tags tag1 AND tag2, possible?

2015-06-04 Thread nusenu
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi, I have a role which supports multiple platforms (Debian, RHEL, FreeBSD, OpenBSD). I use 'when: ansible_pkg_mgr == ...' a lot to autodetect, but that results in a lot of skipping... so I thought I might use tags in addition, so users can choose

Re: [ansible-project] --tags tag1 AND tag2, possible?

2015-06-04 Thread Brian Coca
not currently, a feature request we have is that tags get 'host expressions', so this would look like; tag1:tag2 but there is currently no code that does this On Thursday, June 4, 2015, nusenu nus...@openmailbox.org wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi, I have a role

Re: [ansible-project] --tags tag1 AND tag2, possible?

2015-06-04 Thread nusenu
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Brian Coca: not currently, a feature request we have is that tags get 'host expressions', so this would look like; tag1:tag2 but there is currently no code that does this thanks for the prompt reply. I tried to find that feature

[ansible-project] --tags doesn't work with meta: flush_handlers

2015-04-24 Thread Mark
Setup: --- myrole/main.yml --- - include: somefile.yml tags: configure somefile.yml--- - some command notify: handlerx - meta: flush_handlers --- myrole/handlers/main.yml - handlerx: do something tags: configure Result: - handlerx is not fired with the

Re: [ansible-project] --tags doesn't work with meta: flush_handlers

2015-04-24 Thread Matt Martz
You might want to check out: https://github.com/ansible/ansible/issues/10758 This issue was just fixed recently in devel. On Fri, Apr 24, 2015 at 5:36 PM, Mark markb2...@gmail.com wrote: Setup: --- myrole/main.yml --- - include: somefile.yml tags: configure somefile.yml---

[ansible-project] tags and role dependencies

2014-10-24 Thread Daniel Wendler
Hello @all, i have an strage behavior with role dependencies and tags. I have an playbook like this: --- - name: install and configure a basic set of tools gather_facts: true hosts: - is roles: - { role: monitoring, tags: monitoring } - { role: other, tags: other } In the

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread Michael DeHaan
For starters, ansible --version output? On Fri, Oct 24, 2014 at 5:29 AM, Daniel Wendler daniel.wendler@gmail.com wrote: Hello @all, i have an strage behavior with role dependencies and tags. I have an playbook like this: --- - name: install and configure a basic set of tools

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread James Cammarata
This is happening because you have narrowed the scope of your tags, and the dependent role is only inheriting the monitoring tag from its parent role. If you still need to have your deps run when other tags are specified, you can add them to the list of tags on the dependency: - dependencies: -

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread Michael DeHaan
I'm not sure that's intuitive. By tagging all things with monitoring, everything should get a monitoring. additionally, the included tasks add a monitoring:crc I would expect tags should be additive, and narrowing the scope of your tags is not a thing that should be a language concept IMHO.

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread Daniel Wendler
The version is ansible 1.7.2 (1.7.2+dfsg-2~bpo70+1 - installed from distri repo debian wheezy) Yes, i narrowed the scope of my tag because i want to run only an subset of tasks of the role. But as this are tasks in the monitoring role, i was expecting the dependency is triggered an the

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread James Cammarata
Hi Daniel, Michael and I ran through this and we agree this is operating as expected, since tags applied directly to tasks (like your include statements in tasks/main.yml) are not applied to dependent roles (nor would we expect them to be). So, as I suggested in my reply, you just need to add

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread Michael DeHaan
since tags applied directly to tasks (like your include statements in tasks/main.yml) are not applied to dependent roles (nor would we expect them to be) I may have been confused with the discussion. I do expect tags like this: - hosts: webservers roles: - { role: doit, tags: doit } -

Re: [ansible-project] tags and role dependencies

2014-10-24 Thread Michael DeHaan
Ok, communication issue on my end. doit does get applied to everything, and we are good there (no bugs!) It isn't true that adding a tag to the include statement you have manually inside the role would affect the deps. That would only affect the included tasks in that file. Sorry for

[ansible-project] tags

2014-07-24 Thread Michael Dur
I notice when you try use a tag that does not exist ansible happily prints those that do exist in the error output. Would it be possible/desirable to have an option to just print the tags on demand? How about a tree of playbooks by tags (think of the output of the utility tree)? Our

[ansible-project] tags: all?

2014-04-25 Thread Peter Gehres
Is there any way to have something run for all tags? For example, ec2_facts should always be run when working with hosts in AWS even if you want to use a tag to limit the tasks that you are running. -- Peter Gehres Site Reliability Engineer | AppDynamics, Inc. www.appdynamics.com | AS62897 --

Re: [ansible-project] tags: all?

2014-04-25 Thread Michael DeHaan
Nope, there's no magic all right now. There is already a suggestion for this though (and maybe a pull request). One option is to tag such steps with common and always include common. On Fri, Apr 25, 2014 at 2:47 PM, Peter Gehres peter.geh...@appdynamics.comwrote: Is there any way to

Re: [ansible-project] tags: all?

2014-04-25 Thread Peter Gehres
Aha. Thanks for being the magic index of all open issues :-) https://github.com/ansible/ansible/pull/7039 for anyone wondering. On Fri, Apr 25, 2014 at 1:36 PM, Michael DeHaan mich...@ansible.com wrote: Nope, there's no magic all right now. There is already a suggestion for this though

[ansible-project] tags as variables

2013-11-21 Thread shirou
Hi list, I want to use tags in my playbook as variables. --- - hosts: local user: root tasks: - name: get tag debug: msg={{ tags }} tags: doit and run $ ansible-playbook -i hosts tag_test.yml -t doit but I got TASK: [get tag]