This subordinate Charm fetches an ansible playbook from a git repository
and then executes it in the context of the main charm.
- ops ›
This subordinate charm runs an Ansible playbook, in a git repository, against localhost.
The charm performs the following operations, in the context of the main charm:
clone a git repository, which should contain an Ansible playbook (
prepare an Ansible inventory and execute the cloned playbook (
check at regular intervals if the playbook needs to be executed again (
The rationale behind this charm is that:
the idempotency provided by Ansible seems to match the idempotency required by Juju charm hook implementations
there are several ready to go Ansible playbooks available online (and inside organizations)
DevOps which prefer Ansible over scripting are facilitated.
Ansible charm users should be aware that race conditions may arise if the main charm and the subordinate Ansible charm modify the same resources.
juju deploy cs:ubuntu juju deploy cs:ansible simpleansible juju config simpleansible git_repo="https://git.garr.it/clauz/simpleansible.git" juju config simpleansible ansible_playbook_yaml="main.yaml" juju add-relation ubuntu ansible
- (string) Inventory directory, relative to the git repository root. In this way, inventory directories such as group_vars and host_vars can be made available to Ansible.
- (string) Optional host group to which localhost is added.
- (boolean) Set the -b flag in the ansible-playbook command.
- (string) Only run plays and tasks tagged with these values (-t option of the ansible-playbook command).
- (string) The filename of the main YAML in the playbook to be executed.
- (string) Optional bash expression to be evaluated at the update hook (every 5 minutes). The expression should check for a condition to hold (e.g. the presence of a specific parameter in a configuration file). Thus, if the expression returns 0 (true), the playbook is NOT executed. Else, the playbook is executed. Please note that the playbook is executed unconditionally in all the other cases, i.e. when the configuration changes, a relation is joined, etc.
- (string) git branch to check out after cloning the git repository.
- (string) Optional SSH private key that can be used to clone the git repository over SSH.
- (string) URL of the git repository to be cloned. It should contain a playbook. The URL can be any of the URLs supported by the git client. Thus, URLs such as http://username:email@example.com/myplaybook.git can also be provided.