Ansible is a Configuration Management System that is very simple to use, because of its straightforward and robust model for managing automation and it’s low barrier to entry for ease of use in both development and production.
During OpenStack development, Ansible can be used in conjunction with Vagrant and Devstack to manage complex, multi-node development environments with relative ease.
In this presentation, Juergen Brendel and David Lapsley review Ansible and provide some sample playbooks to get developers up and running quickly. They also describes how to use Ansible, Vagrant, Devstack, and OpenStack to accelerate OpenStack development cycles.
5. Dev, Test, Deploy
Why didn't we
catch this bug
in testing?
We can't
reproduce the
issues.
6. Dev, Test, Deploy
Why didn't we
catch this bug
in testing?
We can't
reproduce the
issues.
I don't have
access to our
test server.
7. Dev, Test, Deploy
Why didn't we
catch this bug
in testing?
How do I setup
my
development
environment?
We can't
reproduce the
issues.
I don't have
access to our
test server.
8. Dev, Test, Deploy
Why didn't we
catch this bug
in testing?
How do I setup
my
development
environment?
We can't
reproduce the
issues.
I don't have
access to our
test server.
“It works for me...”
(shrug)
9. Dev, Test, Deploy
Why didn't we
catch this bug
in testing?
How do I setup
my
development
environment?
We can't
reproduce the
issues.
I don't have
access to our
test server.
“It works for me...”
(shrug)Wouldn't this be nice instead?
Single command: Dev environment created
Single command: Test environment created
22. Ensure all
system packages
are updated.
CM Tools
Describe the desired state
Ensure that user
“xyz” exists.
Ensure package
“apache” is
installed.
23. Ensure all
system packages
are updated.
CM Tools
Describe the desired state
Ensure that user
“xyz” exists.
Ensure package
“apache” is
installed.
Have latest
sources: Clone
repo, update if it
exists already.
24. Ensure all
system packages
are updated.
CM Tools
Describe the desired state
Ensure that user
“xyz” exists.
Ensure package
“apache” is
installed.
Have latest
sources: Clone
repo, update if it
exists already.
Ensure package
“postgres” v9.1 is
installed.
25. Ensure all
system packages
are updated.
CM Tools
Describe the desired state
Ensure that user
“xyz” exists.
Ensure package
“apache” is
installed.
Have latest
sources: Clone
repo, update if it
exists already.
Ensure package
“postgres” v9.1 is
installed. Ensure DB
“app_data” exists
with password
“****”.
29. Puppet (2005)
“powerful, feature-rich, enterprise-y”
Chef (2009)
Salt (2011)
“simple, fast, good for most things”
Ansible (2012)
Fabric (2011)
“not really CMS tools”
Scripts
CM Tools variety
31. • “Orchestration engine” for CM and deployment
• Written in Python
• Uses YAML
• “Playbooks”
• Config specs or explicit commands
Ansible overview
32. • Key Points:
• No central configuration server
• No key management
• No agent to install on target machine
• Explicit order
Ansible simplicity
33. • Key Points:
• No central configuration server
• No key management
• No agent to install on target machine
• Explicit order
• Requirements:
• Need SSH access (with key or password)
• Need Python installed on target machine
Ansible simplicity
37. Modules
Hundreds of them. They know how to do stuff…
Command
Shell
Script
Copy
Sync
Templates
Line ops
38. Modules
Hundreds of them. They know how to do stuff…
Command
Shell
Script
Copy
Sync
Templates
Line ops
Install packages
Users and groups
Networking
Services
39. Modules
Hundreds of them. They know how to do stuff…
Command
Shell
Script
Copy
Sync
Templates
Line ops
Install packages
Users and groups
Networking
Services
Repositories
Message queues
Monitoring
Notification
40. Modules
Hundreds of them. They know how to do stuff…
Command
Shell
Script
Copy
Sync
Templates
Line ops
Install packages
Users and groups
Networking
Services
Repositories
Message queues
Monitoring
Notification
Web servers
Database servers
Cloud infra
59. • Best practices layout for arranging Ansible playbooks,
variables, templates, metadata, etc.
• Better suited for larger projects
• More extensible
Best Practice Project Layout
76. Use Vagrant to spin-up VMs
local (VirtualBox, VMware, etc.)
cloud (EC2)
Use Ansible as 'provisioner'
Make an inventory file with just your VM
Point at same playbook as before
Vagrant
77. • Tells vagrant which VMs to construct
• How to construct them:
• RAM
• Virtual CPUs
• Network interfaces (public, private, static, nat’d)
Vagrant config: Vagrantfile
78. Vagrant.configure(2) do |config|
config.vm.box = "saucy64"
config.vm.box_url = "http://cloud-
images.ubuntu.com/vagrant/..."
config.vm.host_name = "myapp-test"
config.vm.network "private_network", ip: "192.168.1.2”
config.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
#ansible.verbose = "vvvv"
ansible.inventory_path = "vagrant_hosts"
ansible.host_key_checking= false
end
end
79. • Specifies which VMs/Groups Ansible should run against
Inventory: Vagrant Hosts
86. Desired development/deployment workflow
- Create/update cloud production
servers with Ansible
- Provision servers with Ansible
Local dev
and testing
Cloud
testing
Cloud deployment
89. • Same Ansible playbooks can be used to provision
application locally or in the cloud
Key Takeaways
90. • Same Ansible playbooks can be used to provision
application locally or in the cloud
• With cloud APIs and Ansible modules (OpenStack, AWS,
Rackspace, …) playbooks can also be used to provision
infrastructure
Key Takeaways