a manifest/playbook multiple times: nothing will change after the “target state” is reached Separation of configuration and “script” Configuration data can be separated from manifests/ playbooks (passwords) Modularisation and Extension You can modularise (and reuse) manifests/playbooks and extend both tools (Puppet: Ruby; Ansible: Python)
Server pull push - each “Node” must have a running daemon that asks the server for changes - Setting up the server can be daunting - each “Node” must have sshd running and an SSH key installed - The server just needs Ansible (+ Python and some SCM) Node Node Node Node Node
3. Playbooks - which hosts? - “groups” of hosts? db: ram: 2GB "ansible_distribution_version": "14.04" - “facts”: the current state of my hosts - “variables”: properties of hosts (future state, config files, …) - hosts: a00 tasks: - apt: name=nginx - service: ... - what should be “done” on my hosts (future state)
tasks: - name: ensure user mysql exists user: name=mysql - name: install mysql packages apt: name= mysql-server update_cache=yes … - name: create DB user mysql_user: > name=media password=“{{db_password}}” … - name: start service service: name=mysql A “script” that describes the steps to the target state of the machine for which “hosts” (from the inventory) shall the Playbook be applied the list of target states (tasks/ changes) each task (should have) has a name all tasks are implemented by “modules” (“user”, “apt”, …)
=> '3306', ) { package { 'mysql-server': ensure => present, } service { 'mysql': ensure => running, require => Package[“mysql-server”], } [...] } class { “mysql”: root_password => “uncle”, } this is called a declaration (only once!) this is called a class definition a class is a collection of resources these are called resources declaration of ordering variables may be given directly
ntp::service file { … } } class app Execution Model 26 class? include? contain? class mysql class { “app” class postgresql class ntp::service definition resource-like declaration include-like declaration resource-like declaration + containment resource (implies containment)
ntp::service file { … } } Execution Model 28 class? include? contain? definition resource-like declaration include-like declaration resource-like declaration + containment 1.will not be applied before container is applied 2.will be applied before container is finished resource (implies containment) no promise whatsoever when the classes will be applied
db tasks: - name: ensure user mysql exists user: name=mysql - name: install mysql packages apt: name= mysql-server update_cache=yes … - name: create DB user mysql_user: > name=media password=“{{db_password}}” … - name: start service service: name=mysql Execute the tasks in the given order
notion of resources and a target state — developed over 10 years http://www.istockphoto.com/vector/white-background-three-dragons-on-the-ring-of-mebius-18666111
whole catalog every N minutes • continuously update all servers (when a manifest has changed) • execute regularly or execute when needed (deployment) • execute “everything” or a single playbook
Configuration OS Packages Application Configuration OS Packages Application Configuration OS Packages Application Configuration slave OS Packages Application Configuration OS Packages Application Configuration 1.0 1.0 㱺 1.1 1. create DB backup 2. apply DB scripts on master DB 3. configure haproxy not to use the ‘right’ to nodes (not shown) 4. wait 30 minutes 5. stop service 6. deploy version 1.1 on the ‘right’ nodes 7. start service 8. run smoke tests 9. manually check that everything is okay 10.configure haproxy … 11.start over at 3. for left nodes
DB scripts on master DB 3. configure haproxy not to use the ‘right’ to nodes (not shown) 4. wait 30 minutes 5. stop service 6. deploy version 1.1 on the ‘right’ nodes 7. start service 8. run smoke tests 9. manually check that everything is okay 10.configure haproxy … 11.start over at 3. for left nodes the notion of a target state makes things like stopping a service and starting it later difficult to achieve (you have to use “exec” a lot)
on minor versions” • an incredible amount of modules (quite some are not maintained and incompatible with Puppet 4.0) • using the “future parser” delivers error messages that are plain wtf? Maturity http://www.istockphoto.com/photo/favela-11677973
for 100M) • Ansible 2.0 is 99% backward compatible (though a complete rewrite internally) • a rather big amount of modules (but not as many as for Puppet) Maturity http://www.mikestimpson.com/photography/
master/slave • Install puppet on all nodes (or the agent) • Install git and check out your puppet manifests on all nodes (or register the agent with the master) • Install Ansible on one machine • Add an SSH key to the nodes and you are good to go
and mature community. Puppet was a great option for many years, however its user experience is now well behind that of Ansible and Salt. The learning curve is high and it feels heavy and over-engineered, but not quite as bad as Chef.” https://valdhaus.co/books/taste-test-puppet-chef-salt-stack-ansible.html cc-by licensed Flickr photo by Inha Leex Hale (http://www.flickr.com/photos/sixmilliondollardan/)
some reason it "just clicked" whereas I really struggled with Puppet / Chef / or old-school shell scripts. (That says more about me than Puppet and Chef) For me, YAML files and fantastic documentation made more sense than the DSLs of the other two.” https://news.ycombinator.com/item?id=9327970
is its large and mature community. Puppet was a great option for many years, however its user experience is now well behind that of Ansible and Salt. The learning curve is high and it feels heavy and over-engineered, but not quite as bad as Chef.” “Love Ansible for its simplicity. For some reason it "just clicked" whereas I really struggled with Puppet / Chef / or old-school shell scripts. (That says more about me than Puppet and Chef) For me, YAML files and fantastic documentation made more sense than the DSLs of the other two.” https://valdhaus.co/books/taste-test-puppet-chef-salt-stack-ansible.html https://news.ycombinator.com/item?id=9327970