Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
- 0.3.0: First functional release.
- 0.4.0: Add support for folders and nested zip archives.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,38 @@ source ./my_file

**What happens**

The plugin creates a temporary directory. It copies all of the files to it.
The plugin creates a temporary directory. What happens then, depends on defined properties.

It will then execute the `exec` file relative to the temporary directory.
* 1st use case: both `resource_dir` and `resource_list` are defined

Plugin renders all of the files defined in `resource_list` with the values \
defined in `template_variables` (if empty, it just copies the files unchanged \
to temporary working directory) and copies rendered files to temporary \
directory. The rest of files inside `resource_dir` directory are copied \
unchanged.

If `resource_dir` is a zip file, its content is being extracted first. If \
there are any zip files defined in `resource_list`, they are also being \
extracted.

* 2nd use case: `resource_dir` is defined and `resource_list` is not

Plugin renders all of the files inside of a directory (or files extracted \
from zip archive) \
defined in `resource_dir` with the values defined in `template_variables`. \
If `template_variables` is not empty, files extracted from `resource_dir` are \
being rendered with them and copied to temporary directory. If `template_variables` \
is empty, then files are just being copied (without rendering).

* 3rd use case: `resource_dir` is not defined and `resource_list` is defined

Plugin renders all of the files in `resource_list` (including these extracted \
from zip files being a part of a `resource_list`) with the values defined in \
`template_variables` and copies them to temporary directory. If \
`template_variables` is empty, then files are just being copied (without \
rendering).

Plugin will then execute the `exec` file relative to the temporary directory.

_Note: By default the plugin looks to execute a file named `exec` in the temporary directory. This may be overridden._

Expand All @@ -47,7 +76,7 @@ _Note: By default the plugin looks to execute a file named `exec` in the tempora

## Operations

There is only one task defined in the plugin `execute`. This function wraps a `subprocess.Popen` [constructor](https://docs.python.org/2/library/subprocess.html#subprocess.Popen).
There is only one task defined in the plugin `execute`. This function wraps a `subprocess.Popen` [constructor](https://docs.python.org/2/library/subprocess.html#subprocess.Popen).

* `cloudify.interfaces.lifecycle.create`
* `implementation: exec.exec_plugin.tasks.execute`
Expand Down
1 change: 1 addition & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloudify-common<=4.4
46 changes: 29 additions & 17 deletions examples/blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ tosca_definitions_version: cloudify_dsl_1_3

imports:
- http://www.getcloudify.org/spec/cloudify/4.3/types.yaml
- https://raw.githubusercontent.com/EarthmanT/cloudify-execution-plugin/0.3/plugin.yaml
- plugin:cloudify-execution-plugin?version=0.4

inputs:

host_ip:
ansible_host:
type: string

username:
Expand All @@ -16,20 +16,32 @@ inputs:
resource_list:
# For Ansible.
default:
- resources/ansible/exec
- resources/ansible/helloworld.yml
- resources/ansible/hosts.tmp
- exec
- helloworld.yml
- hosts.tmp
- id_rsa

node_templates:

application:
type: cloudify.nodes.Execution
properties:
resource_config:
resource_dir: resources/ansible
resource_list: { get_input: resource_list }
relationships:
- type: cloudify.relationships.contained_in
target: host
template_variables:
ansible_host: { get_input: ansible_host }
ansible_user: { get_input: username }
ansible_ssh_private_key_file: id_rsa
# interfaces:
# cloudify.interfaces.lifecycle:
# create:
# inputs:
# resource_config: { get_property: [ SELF, resource_config ] }
# file_to_source: exec
# relationships:
# - type: cloudify.relationships.contained_in
# target: host
# For HELM.
# interfaces:
# cloudify.interfaces.lifecycle:
Expand All @@ -44,12 +56,12 @@ node_templates:
# resource_config: { get_property: [ SELF, resource_config ] }
# subprocess_args_overrides: {'env': {'SCRIPT_NAME': 'uninstall.sh'}}

host:
type: cloudify.nodes.Compute
properties:
ip: { get_input: host_ip }
agent_config:
install_method: remote
port: 22
user: { get_input: username }
key: { get_secret: agent_key_private }
# host:
# type: cloudify.nodes.Compute
# properties:
# ip: { get_input: host_ip }
# agent_config:
# install_method: remote
# port: 22
# user: { get_input: username }
# key: { get_secret: agent_key_private }
Binary file added examples/resources/ansible.zip
Binary file not shown.
14 changes: 4 additions & 10 deletions examples/resources/ansible/exec
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash

sudo apt-get update -y
sudo apt-get install software-properties-common -y
sudo apt-add-repository ppa:ansible/ansible -y

sudo apt-get update -y
sudo apt-get install ansible -y

sudo cp hosts.tmp /etc/ansible/hosts

ansible-playbook helloworld.yml
/opt/cfy/embedded/bin/virtualenv ansible
source ansible/bin/activate
pip install ansible
ansible-playbook --inventory hosts.tmp helloworld.yml
4 changes: 2 additions & 2 deletions examples/resources/ansible/helloworld.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- hosts: all
- hosts: jumper
tasks:
- shell: echo "hello world"
- shell: echo "hello {{ ansible_host }}"
7 changes: 6 additions & 1 deletion examples/resources/ansible/hosts.tmp
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
localhost ansible_connection=local
hosts:
jumper:
ansible_host={{ ansible_host }}
ansible_connection: ssh
ansible_user: {{ ansible_user }}
ansible_ssh_private_key_file: {{ ansible_ssh_private_key_file }}
27 changes: 27 additions & 0 deletions examples/resources/ansible/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAoLHaq/BKxQwPpbnCZJyZxFVikaGIfszcU0RLFaaZh+dtCAAB
M4xpQEBUHm2ZDscNp+qzUYpvVu4VmEd15wAZ20sB9Oy3eHK2hp95hbLIMQAG8fvP
cw6d0tyltdBypNkgeDg4e9S0skc5Z9LPI6RPJ83AiO12Vex8TcJ6s5Im6e723Igf
G5+1GhH0Ajzeu3j5zGudiaZR8rc0s7gzG/ifPRhr/V5vE0oOyRg4CvwU/nWpIN4g
V5AnyKmJbwRBGxLhxXiGZmyQSWpeuGXX7y+dakXVX9tPs5NQTMcKN9XBXv0a6COE
TmZgVd9Ijgda8O6LckY65QOQPEyKuYJBimfmfwIDAQABAoIBAQCcs/Of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LJK49zqD/Bo6q/rkspKYBCOfAuHQoCyboYNKmAk9aebe
XKnecMl2b98MYdfcXe+EFRr5/AyCrjehZAmsqi/CnD1mpJFEe/pgs4+JzdEuU/kx
xZTG5PH3KB99ZWbIphA3NKZkk3PA7JuctqC3N5XhAuj+dSiTLGbQMQ==
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions examples/resources/ansible/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgsdqr8ErFDA+lucJknJnEVWKRoYh+zNxTREsVppmH520IAAEzjGlAQFQebZkOxw2n6rNRim9W7hWYR3XnABnbSwH07Ld4craGn3mFssgxAAbx+89zDp3S3KW10HKk2SB4ODh71LSyRzln0s8jpE8nzcCI7XZV7HxNwnqzkibp7vbciB8bn7UaEfQCPN67ePnMa52JplHytzSzuDMb+J89GGv9Xm8TSg7JGDgK/BT+dakg3iBXkCfIqYlvBEEbEuHFeIZmbJBJal64ZdfvL51qRdVf20+zk1BMxwo31cFe/RroI4ROZmBV30iOB1rw7otyRjrlA5A8TIq5gkGKZ+Z/
Loading