14
Fellipe Callegas

Ansible to provision your machines

Embed Size (px)

Citation preview

Page 1: Ansible to provision your machines

Fellipe Callegas

Page 2: Ansible to provision your machines

× Software Developer at× Overwatch Player× Science Enthusiast× Center-forward Ronaldo’s Style

Fellipe Callegas

Page 3: Ansible to provision your machines

What’re we going to talk about❏ What's Ansible?❏ Structure❏ How it works❏ Case

Page 4: Ansible to provision your machines

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.

Page 5: Ansible to provision your machines

Structure❏ Inventory❏ Modules❏ Tasks❏ Playbooks

Page 6: Ansible to provision your machines
Page 7: Ansible to provision your machines
Page 8: Ansible to provision your machines
Page 9: Ansible to provision your machines

× FILES

× HANDLERS

× TASKS

× TEMPLATES {{var}}

× VARS

Page 10: Ansible to provision your machines

$ 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

Page 11: Ansible to provision your machines

# 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 }}

Page 12: Ansible to provision your machines
Page 13: Ansible to provision your machines
Page 14: Ansible to provision your machines

Thanks!Any questions?

You can find me at:

Github: callegas

Linkedin: Fellipe Callegas

Blog: callegasdev.wordpress.com