Part of the blog: New In StackStorm: Ansible Integration
This is quick demonstration of the StackStorm automation platform running with Ansible configuration management pack.
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.
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:
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 ansible command) against localmaster
machine - Test
ansible.command
actions (ad-hoc ansible command) against both localmaster
and remotenode1
node2
machines - Test
ansible.galaxy
actions, install, list and then remove roles installed from Ansible Galaxy - Test
ansible.vault
actions, encrypt/decrypt playbooks and run them - Test
ansible.playbook
action, run nginx.yml playbook against all machines - Let the nginx on latest node greet your cat (what?!), have fun
Some of the commands:
# 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-galaxy.sh
, ansible-vault.sh
and ansible-playbook.sh
,
which are usual Vagrant shell provisioner scripts.