https://github.com/stackstorm/st2-ansible-vagrant
Demo showing Ansible integration with StackStorm
https://github.com/stackstorm/st2-ansible-vagrant
Last synced: 10 months ago
JSON representation
Demo showing Ansible integration with StackStorm
- Host: GitHub
- URL: https://github.com/stackstorm/st2-ansible-vagrant
- Owner: StackStorm
- License: apache-2.0
- Created: 2015-05-15T15:49:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-12-20T21:53:31.000Z (about 7 years ago)
- Last Synced: 2023-03-22T17:34:43.725Z (almost 3 years ago)
- Language: Shell
- Size: 30.3 KB
- Stars: 14
- Watchers: 17
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
StackStorm with Ansible on Vagrant demo
===========

> Part of the blog: [New In StackStorm: Ansible Integration](https://stackstorm.com/2015/06/05/new-in-stackstorm-ansible-integration/)
### Introduction
This is quick demonstration of the [StackStorm](http://stackstorm.com/) automation platform running with [Ansible configuration management pack](https://github.com/StackStorm/st2contrib/tree/master/packs/ansible).
It will get you up and running with `master` VM running all St2 components as well as Ansible.
Additionally, it installs 2 clean Ubuntu VMs: `node1`, `node2` and performs ansible commands against them.
### Instructions
To provision the environment run:
vagrant up

> Check the results of performed commands in StackStorm control panel:
https://www.master/
username: `demo`
password: `demo`
Don't forget to visit:
* http://www.node1/
* http://www.node2/
### Explanation
Everything below is performed as part of Vagrant provision:
* Install st2 platform and verify installation
* Install st2 `ansible` pack from remote repository
* Copy ansible configuration files from vagrant shared directory into '/etc/ansible' on `master`
* Test `ansible.command_local` actions ([ad-hoc](http://docs.ansible.com/intro_adhoc.html) ansible command) against local `master` machine
* Test `ansible.command` actions ([ad-hoc](http://docs.ansible.com/intro_adhoc.html) ansible command) against both local `master` and remote `node1` `node2` machines
* Test `ansible.galaxy` actions, install, list and then remove roles installed from [Ansible Galaxy](https://galaxy.ansible.com/)
* Test `ansible.vault` actions, encrypt/decrypt playbooks and run them
* Test `ansible.playbook` action, run [nginx.yml playbook](ansible/playbooks/nginx.yml) against all machines
* Let the nginx on latest node greet your cat (what?!), have fun
Some of the commands:
```sh
# Run simple ansible.command locally
st2 run ansible.command_local args='echo $TERM'
# Run 'hostname -i' ansible.command on all machines (master and nodes)
st2 run ansible.command hosts=all args='hostname -i'
# Ping all machines in 'nodes' group
st2 run ansible.command hosts=nodes module_name=ping
# Install nginx via playbook on all machines
st2 run ansible.playbook playbook=/etc/ansible/playbooks/nginx.yml
# Run nginx playbook on latest node machine, set nginx index.html welcome message
st2 run ansible.playbook playbook=/etc/ansible/playbooks/nginx.yml extra_vars='welcome_name=Tom' limit='nodes[-1]'
...
```
For all commands executed see: [`ansible.sh`](ansible.sh), [`ansible-galaxy.sh`](ansible-galaxy.sh), [`ansible-vault.sh`](ansible-vault.sh) and [`ansible-playbook.sh`](ansible-playbook.sh),
which are usual Vagrant shell provisioner scripts.
### Related Resources
* [Ansible & ChatOps w StackStorm Tutorial & Vagrant demo :rocket:](http://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/)
* [Ansible integration Pack](https://github.com/StackStorm/st2contrib/tree/master/packs/ansible)