Is there something like puppet librarian or R10K for Ansible?

391 views
Skip to first unread message

Jeffrey Lee

unread,
Aug 28, 2015, 4:12:12 PM8/28/15
to Ansible Project
I'm looking for a way to manage different versions of Ansible roles that I am writing when deploying applications. For instance if one application needs v1 of an Ansible role I wrote and another application needs v2 of an Ansible role, is there a tool like puppet librarian or R10K that I can use with Ansible that will assemble the entire Ansible package for me with the correct versions of the roles?

Thanks for any help!

-Jeff

James Martin

unread,
Aug 29, 2015, 4:38:29 PM8/29/15
to Ansible Project

Serge van Ginderachter

unread,
Aug 29, 2015, 5:40:24 PM8/29/15
to ansible...@googlegroups.com
​This sets one time requirements on which role to install​ when starting up a project, this by no means manages versions of the code to deploy an application, depending on versions of applications/hosts/... which would come from inventory data.

Jeffrey Lee

unread,
Aug 30, 2015, 11:31:05 AM8/30/15
to Ansible Project
Perhaps I'm missing it but when you say inventory data do yo meant he hosts in the inventory file? how do you specify specific versions of roles in the inventory file. I am in the midst of Googling it but figured I would see if I was misunderstanding.

-Jeff

Serge van Ginderachter

unread,
Aug 30, 2015, 11:59:49 AM8/30/15
to ansible...@googlegroups.com

On 30 August 2015 at 17:31, Jeffrey Lee <le...@g.harvard.edu> wrote:
Perhaps I'm missing it but when you say inventory data do yo meant he hosts in the inventory file? how do you specify specific versions of roles in the inventory file. I am in the midst of Googling it but figured I would see if I was misunderstanding.

​Sorry, it was my point that this is not possible, and the role requirements​ ar
​e​
no help in that.

Javier Palacios

unread,
Aug 31, 2015, 11:27:16 AM8/31/15
to ansible...@googlegroups.com
On Fri, Aug 28, 2015 at 10:01 PM, Jeffrey Lee <le...@g.harvard.edu> wrote:
I'm looking for a way to manage different versions of Ansible roles that I am writing when deploying applications. For instance if one application needs v1 of an Ansible role I wrote and another application needs v2 of an Ansible role, is there a tool like puppet librarian or R10K that I can use with Ansible that will assemble the entire Ansible package for me with the correct versions of the roles?
 
In case you didn't know roles are looked up wherever inventory lives _and_ wherever the playbook lives (this one rules). So you can keep your standard roles along the inventory and the higher version ones along the playbooks where they are used. It might not suit your needs, and it will potentially end in as many directories as playbooks you have, but might help.

Javier Palacios

Jeffrey Lee

unread,
Aug 31, 2015, 4:23:00 PM8/31/15
to Ansible Project
How would you store roles with your inventory? Isn't the inventory file just a grouping of hosts?

-Jeff

Greg DeKoenigsberg

unread,
Aug 31, 2015, 5:24:50 PM8/31/15
to Ansible Project
On Mon, Aug 31, 2015 at 4:23 PM, Jeffrey Lee <le...@g.harvard.edu> wrote:
> How would you store roles with your inventory? Isn't the inventory file just
> a grouping of hosts?

Well, it's a grouping of hosts and variables. If I understand Javier's
intent, I think he's suggesting that you use variables in inventory
files to specify the role versions that you want to access.

--g
> --
> 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/3ab83cd2-259f-4a04-bced-43c048fc58a2%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Greg DeKoenigsberg
Ansible Community Guy

Find out why SD Times named Ansible
their #1 Company to Watch in 2015:
http://sdtimes.com/companies-watch-2015/

Serge van Ginderachter

unread,
Sep 1, 2015, 5:11:34 PM9/1/15
to ansible...@googlegroups.com
​​
​Hi all,


I have been a bit lurking on this thread, as I find the subject very interesting, and have been loging to solve similar use cases.​

First of all, to answer Jeffrey Lee's initial question, no, ansible does not have anything specific to manage versions of playbooks/roles. I might have an idea on how to hack it into ansible currently, but I'm not sure that would scale well. See further down this post on this idea.

My use case primarily involves what could be called something like an application's life cycle manageent. Let me give a more or eless simple example.
My main $cust is a Java shop, and manages around 100+ different Tomcat applications. This basically translates to 1 tomcat role to deploy all of them, with differences between the application being defined withing the appliactions artefact/code - obviously - ​and other parameters in the inventory.

This leads to two problems: easily manage e.g. the needed java version and tomcat version, per application, per version of the application, and this separately for every environment (development, testing, staging, production, ...) where the app gets deployed. This can be done of course with inventory variables, but standard ansible inventory (the ini files) don't scale well when you have 600-1000 apps-environments to manage and to have those variables evolve. Some higher level application exporting it's data with an Ansible Inventory script come to mind here.

Now this is only one part: managing parameters in the inventory. Managing role versions is another one. Granted, there is an overlap: e.g. tomcat and java versions could be hard coded in a specific role version for that app.

The main issue one wants here, is tightly coupling a specific version of the application to a specific version of whatever deploys that application. (Yes, part of that is what docker tries to do, but docker is only a tool here, one still has to manage the application in its total lifecycle.)

A big part of this is IMHO important when thinking of the future of the Ansible inventory - which is one of the reasons I bring this up here.

(
On a side note, I have been thinking the Inventory should be able to be The Single Source of Truth for your infra. At that point, the difference between inventory and facts caching might stop to exist. Small example: I could configure in inventory to deploy version X of app Y. But when looking at the inventory, how would I know which is the currently deployed version? If I have multiple nodes for app Y, I might be upgrading them over a longer amount of time. So the configured version X might apply to some of the nodes, whilst others still have X-1. The last deployed version is a fact that results of a previous deploy, which I'd like to keep track of in my inventory.
)


But I digressed. Back to the OP's question, a possible solution with current stable Ansible (up to 1.9***), could be this:
  1. version all your roles
  2. ​​
    multiple versions of a role means those multiple instances live next to each other on the file system, not multiple versions in some VCS
  3. define groups for your
    ​ each​
    applications: appA
    ​ (and probably will need appA-dev, appA-test, appA-prod)​, which will hold the nodes for this app
  4. define a matching group in inventory for every role-version you have: roleA-versionX
  5. ​define playbooks that match role roleA-versionX to the group roleA-versionX
  6. have you
    ​r​
    appA group become a child of the roleA-versionX
    ​, as to match the application to a role version
  7. as this evolves, move appA from roleA-versionX to roleA-versionY
Managing the groups roleA-versionX could perhaps be handled by the group_by module, from version variables for appA
Perhaps part of this might become simplier if some post-v2 (***) would allow dynamic role inclusions based on inventory variables

​This could all be possible within ini files, in theory, but as I said that would scale badly for a larger environments.



Thoughts?



Serge van Ginderachter
(svg on irc, srvg on github)

Javier Palacios

unread,
Sep 2, 2015, 4:24:11 AM9/2/15
to ansible...@googlegroups.com
Its maybe an issue with the expression I did use `where the inventory lives` means under the same directory where is your inventory. So, it looks for roles on /path/to/playbok/roles and then on /path/to/inventory/roles.

Javier Palacios

Reply all
Reply to author
Forward
0 new messages