-
Notifications
You must be signed in to change notification settings - Fork 18
Home
Ansible is installed per deployment. This keeps the file system clean.
Use the code from plugin.yaml.template to install the plugin:
plugins:
cloudify-ansible-plugin:
executor: central_deployment_agent
source: https://github.com/earthmant/cloudify-ansible-plugin/archive/master.zip
In your blueprint, create a node. Add the configure lifecycle operation, and map to the create and validate methods.
ansible_configuration:
type: cloudify.nodes.ApplicationModule
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: cloudify-ansible-plugin.ansible_plugin.configure.create
configure:
implementation: cloudify-ansible-plugin.ansible_plugin.configure.validate
Add a host to an Ansible inventory. This operation takes 3 arguments: host, group, inventory.
-
host: the hostname or ip of a target machine to run a playbook
-
group: required, usually something like 'webservers', 'dbservers', 'north_america1', etc.
-
inventory: a best practices grouping like 'staging', 'production', 'networks', 'printers', or just 'hosts'
target_machine: type: cloudify.ansible.host interfaces: cloudify.interfaces.lifecycle: configure: implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host inputs: host: { get_attribute: { vm, ip } } group: North Dakota inventory: cdn
To run a playbook on an inventory (list of hosts), you can use the run_playbook task.
new_playbook:
type: cloudify.ansible.playbook
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
inputs:
inventory: { get_input : test_inventory_name }
local_file: { get_input : playbook_file }
agent_key: { get_input : agent_key_path }
It is important that these operations run in a proper order. You cannot run a playbook, before you add the host to an inventory.
For example:
target_host:
type: cloudify.ansible.host
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: cloudify-ansible-plugin.ansible_plugin.tasks.add_host
inputs:
host: { get_input: host_ip_or_hostname }
group: { get_input : test_group_name }
inventory: { get_input : test_inventory_name }
apache_playbook:
type: cloudify.ansible.playbook
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
inputs:
inventory: { get_input : test_inventory_name }
local_file: { get_input : playbook_file }
agent_key: { get_input : agent_key_path }
relationships:
- type: cloudify.relationships.depends_on
target: target_host
If you used an existing inventory in the blueprint, this is not a problem.
apache_playbook:
type: cloudify.ansible.playbook
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: cloudify-ansible-plugin.ansible_plugin.tasks.run_playbook
inputs:
inventory: { get_input : existing_inventory_file }
local_file: { get_input : playbook_file }
agent_key: { get_input : agent_key_path }
Just make sure that you actually have a existing inventory file in the blueprint directory.