Is there a way to somehow "reset" variables in-between plays?  What I'm 
trying to do is make a playbook that creates my standard tomcat instance 
layout.

So given the setup below, as I understand it you'd have "app" files 
group_vars where you could set whatever things specific to that app 
instance like port.  Then you'd have in the 
roles/tomcat-7/defaults/main.yml some default values for everything with 
the idea you'd set what you actually care about in the top level 
group_vars/app1.yml and app2.yml such as port number for that specific 
app.  Then you use an inventory file for a given environment (such as 
dev.hosts) to "hook" together a given app with a given group of host(s).  
Then you call ansible-playbook passing in the inventory file you care about 
right now (such as dev.hosts), the top level playbook (such as 
tomcat7servers.yml),  Then Ansible would iterate through the playbook ( 
tomcat7servers.yml in this case), taking the group_vars/myapp1 and run the 
tomcat-7 role on the myapp1 group of hosts.  Then the same for myapp2.

That much seems like it works, but the problem I get is that there doesn't 
seem to be a way to say ok, this time around I don't want to do both myapp1 
and myapp2.  I want to limit to just myapp2.  I've tried doing something 
like

ansible-playbook -i dev.hosts tomcat7servers.yml --limit=myapp2

but it picks up both.  Not only that but unless I re-define values from the 
myapp1 "run" it keeps the values from myapp1 when it hits myapp2.  This 
usually suggests I'm not "getting" something about how Ansible models 
things.  What am I "missing" about this picture?  I want to be able to run 
something like I gave above there and have a tomcat 7 on appsvr1.internal 
created that has totally default except for the values explicitly set in 
group_vars/myapp1 and another tomcat 7 on that same box that has totally 
default values except for what's explcitly set in group_vars/myapp2.

/usr/local/apache-tomcat-7.0.51   (where this is just a totally plain tar 
xzf of a tarball off Apache's site extracted as root so it's *NOT* writable)

Then the tomcat instances (owned by app user such as tcadm):
/appl/app1/
then under that
/bin
/conf/
/webapps
and so on


/appl/appt2/
same setup as app1 here, but different ports, different instance name


So, trying to extrapolate from Ansible best practices in the documentation 
the local "repo" is something like this

roles/tomcat-7/defaults/main.yml (where you'd set things you don't normally 
care about overriding like maxAjpThreads but you *could* override what's in 
the group_vars top level)
roles/tomcat-7/tasks
roles/tomcat-7/templates
and so on

group_vars/ (where you'd have yml files with the values for a given 
app-such as myapp1.yml, myapp2.yml)
(example myapp1.yml)
ajpPort: 8109
httpPort: 8180
instanceName: myapp1
(example myapp2.yml)
ajpPort: 8209
httpPort: 8280
instanceName: myapp2



dev.hosts (which would match up group_names (such as myapp1 and myapp2) to 
actual hosts in dev environment)
(example dev.hosts)
[myapp1]
appsvr1.dev

[myapp2]
appsvr1.dev

tomcat7servers.yml ("matching" groups for the inventory to actual roles)
- hosts: myapp1
  become_user: tomcat
  roles:
  - tomcat-7
  tasks:
  - include_vars: group_vars/myapp1.yml

- host: myapp2
  become_user: tomcat
  roles:
  - tomcat-7
  tasks:
  - include_vars: group_vars/myapp2.yml



-- 
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/fb7f72cc-5e29-4164-8bfd-121f49aabaeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to