I have a use case for Ansible where I have several code bases (say, C_A and
C_B), and several services (S_A1, S_A2, S_B1, S_B2). Here S_A1 and S_A2 are
essentially different executables from the same repo containing C_A. It's
relatively easy to model the dependency such that when a node is running a
service, the dependent code base is deployed.
What I need is to write a somewhat generic playbook to upgrade a code base
(say C_A) on all or a group of nodes. And if a node is running a
corresponding service (say S_A1), the service must be stopped first,
perform upgrade, and restart the service.
Ideally, I want to be able to do something like: "ansible-play -i nodes
upgrade.yml -e code_base=C_A --limit group-test"
I've thought about modeling C_* and S_* as roles, and use role dependency
to link them. But I am not sure if we can iterate through all the nodes
that take a particular role.
Another way might be to define two levels of groups, a group of nodes that
runs a service, and a group of services that should run a code base. In
this case, at least we might be able to write a playbook like:
- hosts: "group_{{ code_base }}"
roles:
- { role: role_code_base, name: "{{ code_base }}"}
But in this case, I am not sure how to trigger the right services to
reload, and stop them all in the first place.
Any ideas? Thanks..
--
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].
For more options, visit https://groups.google.com/groups/opt_out.