forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request redhat-cop#34 from RedHatDemos/master
RH Demos adds
- Loading branch information
Showing
78 changed files
with
6,007 additions
and
0 deletions.
There are no files selected for viewing
224 changes: 224 additions & 0 deletions
224
ansible/cloud_providers/ravello/Ansible_Ravello_module.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
:scrollbar: | ||
:data-uri: | ||
:toc2: | ||
|
||
== Requirements & Instructions on Using the Ansible Ravello Module | ||
|
||
:numbered: | ||
|
||
== Requirements | ||
|
||
. Install Ansible `http://docs.ansible.com/ansible/intro_installation.html` | ||
. Install the Ravello SDK via **pip** | ||
+ | ||
NOTE: For manual setup instructions see `https://github.com/ravello/python-sdk` and for additional documentation see `http://ravello-sdk.readthedocs.io/en/ravello-sdk-1.4/` | ||
+ | ||
---- | ||
pip install ravello-sdk | ||
---- | ||
|
||
=== Test Ravello SDK | ||
|
||
. Clone the ravello-sdk locally to use the example scripts | ||
+ | ||
---- | ||
cd <desired_dir> | ||
git clone https://github.com/ravello/python-sdk.git | ||
---- | ||
+ | ||
. Change to the **examples** directory | ||
+ | ||
---- | ||
cd python-sdk/examples | ||
---- | ||
+ | ||
. Set up credentials file for Ravello using your username and password | ||
+ | ||
---- | ||
./set-creds | ||
Enter username: [email protected] | ||
Enter a Password: | ||
---- | ||
+ | ||
. Verify saved credentials | ||
+ | ||
NOTE: This will display your login into on the terminal however the password is hashed. | ||
+ | ||
---- | ||
cat ~/.ravello_login | ||
<username> | ||
<password> | ||
---- | ||
+ | ||
. Test the script to get all blueprints you have access to | ||
+ | ||
---- | ||
./bp-get-all | ||
<all blueprints you have access to> | ||
---- | ||
|
||
=== Test Capture of Ravello Environment Metadata to JSON | ||
|
||
. Test the script to get all applications you have access to | ||
+ | ||
---- | ||
./app-get-all | ||
<all apps you have access to> | ||
---- | ||
+ | ||
. Test the script to get all metadata for a specific application and write it to a JSON file | ||
+ | ||
NOTE: The option **-a** is for a full JSON dump of extended application metadata | ||
+ | ||
---- | ||
./app-get-data -a <one app name from output in previous step > myapp.json | ||
---- | ||
|
||
== Using the Ravello Ansible Module | ||
|
||
=== Clone the Ansible Ravello Repository | ||
|
||
. Change to a directory of your chosing | ||
+ | ||
---- | ||
git clone https://github.com/RedHatDemos/ansible-ravello.git | ||
---- | ||
|
||
=== Create YAML Template | ||
|
||
. Within the cloned repository directory, create template from existing app: | ||
+ | ||
---- | ||
./app-get-data -a <your_application> 2>/dev/null|python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' > out.yaml | ||
---- | ||
|
||
. Remove everything that is not in the *design:* section. This is at the beginning and end of the file. | ||
|
||
. Under *design:* remove all subsections except *vms:* | ||
|
||
. Remove any line with *applicationId:*, *creationTime:*, *loadingStatus:*, *loadingPercentage:*, *fqdn:*, *allocatedIp:*, *externalAccessState:*, *ipConfigLuid:*, and *useLuidForIpConfig:*. | ||
|
||
=== Deploy an Environment | ||
|
||
. This playbook will create a blueprint based on a set of virtual machines described in *app_template.yml*. It will then create an application from this blueprint and wait for it to start. | ||
|
||
. To use the default values just run the *deploy_environment.yml. | ||
+ | ||
---- | ||
ansible-playbook deploy_environment.yml | ||
---- | ||
|
||
+ | ||
NOTE: It is likely there may be a conflict if the default names have already been used. Instead, specify a *unique_name* and optionally a *version* which will be used to make sure your blueprints and applications have unique names | ||
+ | ||
. Specify *unique_name* and *version* if desired: | ||
+ | ||
---- | ||
ansible-playbook deploy_environment.yml -e "unique_name=vvaldez-demo version=1.6" | ||
---- | ||
|
||
. It is also possible to load your own variables from a yaml file: | ||
+ | ||
---- | ||
ansible-playbook deploy_environment.yml -e @vars.yml | ||
---- | ||
|
||
. Contents of *vars.yml*: | ||
+ | ||
---- | ||
unique_name=vvaldez-demo | ||
version=1.6 | ||
---- | ||
|
||
. To skip the blueprint creation phase, just provide an existing *blueprint_id*: | ||
+ | ||
---- | ||
ansible-playbook deploy_environment.yml -e "blueprint_id=12345678" | ||
---- | ||
|
||
. Example *deploy_environment.yml* playbook template provided in this repo: | ||
+ | ||
---- | ||
--- | ||
- hosts: localhost | ||
tasks: | ||
# Create app, based on blueprint, start it and wait for started | ||
- local_action: | ||
module: ravello_app | ||
# Make sure you update the version number as the name must be unique | ||
name: 'example_app-v1.0' | ||
description: 'Example blueprint created by ansible' | ||
app_template: '/home/user/ansible-ravello/app_template.yml' | ||
state: design | ||
---- | ||
+ | ||
[NOTE] | ||
The *name* field must be unique. All blueprints must have a unique name. Typically this is achieved by changing the version number in the name. | ||
|
||
=== Create Blueprint From Template | ||
|
||
---- | ||
ansible-playbook design.yml -vvv | ||
---- | ||
|
||
---- | ||
Using /etc/ansible/ansible.cfg as config file | ||
[WARNING]: provided hosts list is empty, only localhost is available | ||
PLAYBOOK: design.yml *********************************************************** | ||
1 plays in design.yml | ||
PLAY [localhost] *************************************************************** | ||
TASK [setup] ******************************************************************* | ||
Using module file /usr/lib/python2.6/site-packages/ansible/modules/core/system/setup.py | ||
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: prutledg | ||
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313 `" && echo ansible-tmp-1481666189.73-18007598170313="` echo $HOME/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313 `" ) && sleep 0' | ||
<127.0.0.1> PUT /tmp/tmp7TPuB1 TO /home/prutledg/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313/setup.py | ||
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/prutledg/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313/ /home/prutledg/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313/setup.py && sleep 0' | ||
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2.6 /home/prutledg/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313/setup.py; rm -rf "/home/prutledg/.ansible/tmp/ansible-tmp-1481666189.73-18007598170313/" > /dev/null 2>&1 && sleep 0' | ||
ok: [localhost] | ||
TASK [ravello_app] ************************************************************* | ||
task path: /home/prutledg/ansible-ravello/design.yml:5 | ||
Using module file /home/prutledg/ansible-ravello/library/ravello_app.py | ||
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: prutledg | ||
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707 `" && echo ansible-tmp-1481666190.57-63460892520707="` echo $HOME/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707 `" ) && sleep 0' | ||
<localhost> PUT /tmp/tmp7TPuB1 TO /home/prutledg/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707/ravello_app.py | ||
<localhost> EXEC /bin/sh -c 'chmod u+x /home/prutledg/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707/ /home/prutledg/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707/ravello_app.py && sleep 0' | ||
<localhost> EXEC /bin/sh -c '/usr/bin/python2.6 /home/prutledg/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707/ravello_app.py; rm -rf "/home/prutledg/.ansible/tmp/ansible-tmp-1481666190.57-63460892520707/" > /dev/null 2>&1 && sleep 0' | ||
changed: [localhost -> localhost] => { | ||
"blueprint_id": "76743737", | ||
"changed": true, | ||
"invocation": { | ||
"module_args": { | ||
"app_template": "/home/prutledg/ansible-ravello/app_template.yml", | ||
"application_ttl": -1, | ||
"blueprint_description": null, | ||
"blueprint_id": null, | ||
"blueprint_name": null, | ||
"cloud": null, | ||
"description": "Example blueprint created by ansible", | ||
"name": "example_app-v1.0", | ||
"password": null, | ||
"publish_optimization": "cost", | ||
"region": null, | ||
"service_name": "ssh", | ||
"state": "design", | ||
"url": null, | ||
"username": null, | ||
"wait": true, | ||
"wait_timeout": 1200 | ||
}, | ||
"module_name": "ravello_app" | ||
}, | ||
"name": "example_app-v1.0" | ||
} | ||
---- | ||
|
||
=== Check for Blueprint | ||
|
||
. Log into Ravello and check if the blueprint exists. | ||
|
||
. The next steps would be to deploy the blueprint with this ansible module as a new application, inventory the app, and apply final playbook(s) to the resulting VMs then create final blueprint from that. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Synopsis | ||
The Ansible Ravello module is intended to provide an easy way to interact with Ravello using the Ravello SDK to interact with the Ravello API. The goal is to use the automation capabilities of Ansible to easily deploy new applications, customize the applications and save the fully configured application back as a blueprint in Ravello allow for quick, scalable, pre-configured deployments. | ||
|
||
# Pre-reqs, Installation, Examples | ||
Refer to: https://github.com/RedHatDemos/ansible-ravello/blob/master/Ansible_Ravello_module.adoc for installation dependencies and module usage. | ||
|
||
# Contributors | ||
The main contributors for this project are: </br> | ||
*Pat Rutledge* [email protected] </br> | ||
*Vinny Valdez* [email protected] </br> | ||
*Nenad Peric* [email protected] </br> | ||
*Brett Thurber* [email protected] |
Oops, something went wrong.