-
Install Ansible
http://docs.ansible.com/ansible/intro_installation.html
-
Install the Ravello SDK via pip
NoteFor manual setup instructions see https://github.com/ravello/python-sdk
and for additional documentation seehttp://ravello-sdk.readthedocs.io/en/ravello-sdk-1.4/
pip install 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
NoteThis 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 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
NoteThe 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
-
Change to a directory of your chosing
git clone https://github.com/RedHatDemos/ansible-ravello.git
-
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:.
-
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
NoteIt 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
NoteThe name field must be unique. All blueprints must have a unique name. Typically this is achieved by changing the version number in the name.
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" }