Fellipe Callegas
× Software Developer at
× Overwatch Player
× Science Enthusiast
× Center-forward Ronaldo’s Style
Fellipe Callegas
What’re we going to talk about
❏ What's Ansible?
❏ Structure
❏ How it works
❏ Case
What’s Ansible?
❏ Management / Automation Tool
❏ Agentless
❏ Very simple
❏ 1000+ modules
❏ Extensible
❏ Idempotent
It's a task automation tool similar to Puppet and Chef, but much more
powerful and the darling of the DevOps staff today.
Structure
❏ Inventory
❏ Modules
❏ Tasks
❏ Playbooks
× FILES
× HANDLERS
× TASKS
× TEMPLATES {{var}}
× VARS
$ ansible-playbook -i hosts site.yml
# This playbook deploys the whole application stack in this site.
- name: apply common configuration to all nodes
hosts: all
remote_user: root
roles:
- common
- name: configure and deploy the webservers
hosts: webservers
remote_user: root
roles:
- web
- name: deploy MySQL and configure the databases
hosts: dbservers
remote_user: root
roles:
- db
[webservers]
web3
[dbservers]
web2
❏ Tasks
❏ Handlers
❏ Templates
# This playbook will install mysql and create db user and give permissions.
- name: Install Mysql package
yum: name={{ item }} state=installed
with_items:
- mysql-server
- MySQL-python
- libselinux-python
- libsemanage-python
- name: Configure SELinux to start mysql on any port
seboolean: name=mysql_connect_any state=true persistent=yes
when: sestatus.rc != 0
- name: Create Mysql configuration file
template: src=my.cnf.j2 dest=/etc/my.cnf
notify:
- restart mysql
- name: Start Mysql Service
service: name=mysqld state=started enabled=yes
# Handler to handle DB tier notifications
- name: restart mysql
service: name=mysqld state=restarted
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links
symbolic-links=0
port={{ mysql_port }}
Thanks!
Any questions?
You can find me at:
Github: callegas
Linkedin: Fellipe Callegas
Blog: callegasdev.wordpress.com

Ansible to provision your machines

  • 1.
  • 2.
    × Software Developerat × Overwatch Player × Science Enthusiast × Center-forward Ronaldo’s Style Fellipe Callegas
  • 3.
    What’re we goingto talk about ❏ What's Ansible? ❏ Structure ❏ How it works ❏ Case
  • 4.
    What’s Ansible? ❏ Management/ Automation Tool ❏ Agentless ❏ Very simple ❏ 1000+ modules ❏ Extensible ❏ Idempotent It's a task automation tool similar to Puppet and Chef, but much more powerful and the darling of the DevOps staff today.
  • 5.
  • 9.
    × FILES × HANDLERS ×TASKS × TEMPLATES {{var}} × VARS
  • 10.
    $ ansible-playbook -ihosts site.yml # This playbook deploys the whole application stack in this site. - name: apply common configuration to all nodes hosts: all remote_user: root roles: - common - name: configure and deploy the webservers hosts: webservers remote_user: root roles: - web - name: deploy MySQL and configure the databases hosts: dbservers remote_user: root roles: - db [webservers] web3 [dbservers] web2 ❏ Tasks ❏ Handlers ❏ Templates
  • 11.
    # This playbookwill install mysql and create db user and give permissions. - name: Install Mysql package yum: name={{ item }} state=installed with_items: - mysql-server - MySQL-python - libselinux-python - libsemanage-python - name: Configure SELinux to start mysql on any port seboolean: name=mysql_connect_any state=true persistent=yes when: sestatus.rc != 0 - name: Create Mysql configuration file template: src=my.cnf.j2 dest=/etc/my.cnf notify: - restart mysql - name: Start Mysql Service service: name=mysqld state=started enabled=yes # Handler to handle DB tier notifications - name: restart mysql service: name=mysqld state=restarted [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links symbolic-links=0 port={{ mysql_port }}
  • 14.
    Thanks! Any questions? You canfind me at: Github: callegas Linkedin: Fellipe Callegas Blog: callegasdev.wordpress.com