2. × Software Developer at
× Overwatch Player
× Science Enthusiast
× Center-forward Ronaldo’s Style
Fellipe Callegas
3. What’re we going to 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.
10. $ 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
11. # 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 }}