Hi,

I want to extract some common stuff from a role that needs to be invoked as 
part of that role.

# BACKGROUND 

I'm just getting started with ansible but I'm having difficulty.

I've got a number of applications which have their own config file, their 
own home user and their own user.  All of these are java services and as 
such will need similar init.d jobs.

I'm working on role which downloads one of the jar (package files) from a 
maven repository and deploys it.

In general the steps are as follows:


   - On the control master download the deployable jar
   - Ensure the user account is present.
   - Copy the jar file to the home folder of the user account
   - Create a configuration sub-folder underneath the users home
   - Copy the application specific configuration to this folder
   - -- NOT DONE YET- Notify the load balancer the application is out of 
   service.
   - .. Other common steps to do with logging
   - *STARTUP STEPS*
   - Create an os specific startup script (SysV or upstart)
   - Ensure the service is started.
   - -- Not done yet -- Create a handler which notifies load balancer 
   application is deployed.
   

# QUESTION:


My problem and my question is how can I extract the common stuff. Creating 
the user (via a variable), setting up the folder that the application has 
permission to log to, to starting the init stuff. 


My initial route (which worked) was to create one role for the application, 
that had its variables files and templates in it and did all of the init 
stuff, but that’s not reusable for other projects.


Now I'd like to create a role for starting a java-service, that could be 
called from the application specific role. That sets- up the common stuff 
to all our Java services. However I can't see how to invoke a role with 

variables during execution of another role. 


Another approach I would consider is creating the application specific role 
as a specialisation of the generic service role, However that doesn't seem 
to make sense either. 


So the problem as I see it is that If I use a playbook to do all these role 
pieces the variables need to be top level and not application specific. If 
I use a role I can't find a way to invoke another set of subtasks(role) 
inside.

Both the service role and the application role would have their own 
templates.


Just looking for the best practice to avoid copy paste.


Wes

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/46d7a84b-47a8-4bbf-a0e7-05a2a9d5357d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to