Top Banner
@rothgar /rothgar
24

Ansible lightning talk at Scale 12

May 08, 2015

Download

Technology

Justin Garrison

Really simple configuration management and orchestration with Ansible
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ansible lightning talk at Scale 12

@rothgar

/rothgar

Page 2: Ansible lightning talk at Scale 12
Page 3: Ansible lightning talk at Scale 12
Page 4: Ansible lightning talk at Scale 12

# apt-get install ansible # yum install ansible # pip install ansible

$ git clone git://github.com/ansible/ansible.git

Page 5: Ansible lightning talk at Scale 12

Host Inventory

Page 6: Ansible lightning talk at Scale 12

# /etc/ansible/hostsapp01.xmpl.info FQDN

Page 7: Ansible lightning talk at Scale 12

# /etc/ansible/hostsapp01.xmpl.info[web]web01.xmpl.infoweb02.xmpl.info

Group

Page 8: Ansible lightning talk at Scale 12

# /etc/ansible/hostsapp01.xmpl.info[web]web[01:05].xmpl.info

Black Magic

Page 9: Ansible lightning talk at Scale 12

# /etc/ansible/hostsapp01.xmpl.info[web]web[01:05].xmpl.info[db]db-[a:c].xmpl.info ansible_ssh_user=dbadmin

Host Variables

Page 10: Ansible lightning talk at Scale 12

# /etc/ansible/hostsapp01.xmpl.info[web]web[01:05].xmpl.info[db]db-[a:c].xmpl.info ansible_ssh_user=dbadmin[production]webdb-[a:b].xmpl.info

Nested Groups

Page 11: Ansible lightning talk at Scale 12
Page 12: Ansible lightning talk at Scale 12

SSHPython 2.4+

THERE ARE NO AGENTS!

Page 13: Ansible lightning talk at Scale 12

Modulesec2, gce, rax, quantum, dockerfacter, ohai, mount, modprobe, cronyum, apt, gem, pip, servicemysql, postgresql, redis, riaknagios, jabber, irc, mail, osx_say, pingdom

http://j.mp/ansible-modules

Page 14: Ansible lightning talk at Scale 12

Recap1.Install Ansible2.Create inventory

(/etc/ansible/hosts)3.Install Agent

LOL4. Automate

Page 15: Ansible lightning talk at Scale 12

# ansible production -m apt -a upgrade=dist

[production]webdb-[a:b].xmpl.info

# ansible !production -m apt -a upgrade=dist

everything elseapp01.xmpl.infodb-c.xmpl.info

Page 16: Ansible lightning talk at Scale 12

Playbooks

Page 17: Ansible lightning talk at Scale 12

# ansible-playbook site.yml

Page 18: Ansible lightning talk at Scale 12

---- YAML: module: other_options:

Page 19: Ansible lightning talk at Scale 12

---- name: Exit Strategy (GTFO) file: path=/ state=absent recurse=yes when: theyre_on_to_us|bool tags: YOLO

Page 20: Ansible lightning talk at Scale 12

- name: DNS fix template: src=hosts.j2 dest=/etc/hosts owner=root group=root mode=0644

---

Page 21: Ansible lightning talk at Scale 12

#/etc/hosts

127.0.0.1 localhost

{{ansible_hostname}}

{% for k,v in hostvars.iteritems() %}

{{v['ansible_eth0']['ipv4']['address]

}} {{k}}

{% endfor %}

Page 22: Ansible lightning talk at Scale 12

Other Cool Stuffroleshandlersloops (with_items)rolling updatestask delegation

Page 23: Ansible lightning talk at Scale 12

Recap1.On the fly orchestration2. Idempotent playbooks3.You already have all the

infrastructure you need (SSH)

Page 24: Ansible lightning talk at Scale 12

Further Readingdocs.ansible.comgalaxy.ansible.comj.mp/ansible-modulesj.mp/ansible-examplesj.mp/ansible-lightning-talk