I'm still pretty new to Ansible, and I'm trying to figure out the proper
method for setting up a role, and then calling only a couple of tasks from
that role from a playbook.
The reason I'm doing so, is I have a group of nodes that need two tomcat
instances running on top of a base instance, but I also have another group
that only needs one tomcat instance. So I've created a very simple role:
---
> - name: install tomcat7
> sudo: True
> apt: name=tomcat7 update_cache=yes cache_valid_time=3600
> tags:
> - wowza
> - name: create directory structure for tomcat_1
> sudo: True
> file: path=/var/opt/tomcat_1/{{ item }} state=directory
> owner=tomcat7 group=nogroup
> with_items:
> - bin
> - conf
> - logs
> - temp
> - webapps
> - work
> tags:
> - java_nodes
> - name: create lib link
> file: src=/usr/share/tomcat7/lib dest=/var/opt/tomcat_1/lib
> state=link
> tags:
> - java_nodes
> - name: create deeper directory structure for tomcat_1
> sudo: True
> file: path=/var/opt/tomcat_1/conf/Catalina/localhost state=directory
> owner=tomcat7 group=nogroup
> tags:
> - java_nodes
> - name: create symlink under tomcat_1/bin
> sudo: True
> file: src=/usr/share/tomcat7/bin/bootstrap.jar
> dest=/var/opt/tomcat_1/bin/bootstrap.jar owner=tomcat7 group=nogroup
> state=link
> tags:
> - java_nodes
> - name: create file structure for tomcat_2
> sudo: True
> file: path=/var/opt/tomcat_2/{{ item }} state=directory
> owner=tomcat7 group=nogroup
> with_items:
> - bin
> - conf
> - logs
> - temp
> - webapps
> - work
> tags:
> - java_nodes
> - name: create lib link
> file: src=/usr/share/tomcat7/lib dest=/var/opt/tomcat_2/lib
> state=link
> tags:
> - java_nodes
> - name: create deeper directory structure for tomcat_2
> sudo: True
> file: path=/var/opt/tomcat_2/conf/Catalina/localhost state=directory
> owner=tomcat7 group=nogroup
> tags:
> - java_nodes
> - name: create symlink under tomcat_2/bin
> sudo: True
> file: src=/usr/share/tomcat7/bin/bootstrap.jar
> dest=/var/opt/tomcat_2/bin/bootstrap.jar owner=tomcat7 group=nogroup
> state=link
> tags:
> - java_nodes
And I'm executing it from this playbook:
---
> - name: Install Oracle Java 7 and tomcat
> hosts: basic_java
> sudo: True
> roles:
> - java
> - { role: tomcat, tags: 'wowza' }
According to the documentation, that should be possible:
http://docs.ansible.com/playbooks_tags.html
You may also apply tags to roles:
>
> roles:
> - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
>
> I have tried this a couple of different ways:
{ role: tomcat, tags: 'wowza' }
>
{ role: tomcat, tags: 'wowza', skip-tags 'java_nodes' }
{ role: tomcat, skip-tags: 'java_nodes' }
But they all execute the entire role.
I'm using Ansible 1.8.2, and running it from a mac, on Ubuntu nodes in
Vagrant.
Am I incorrect in my interpretation of the documentation? Is this not an
allowable way to use tags? And if so, is there a best practices way to
achieve what I'm going for, here? I'd hate to have to create a second
tomcat role - that seems inelegant.
Thank you, and I'm looking forward to your thoughts.
--
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/37fe53d7-d5c9-441c-8c22-737ec3f6759c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.