Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ansible to provision your machines

138 views

Published on

Ansible to provision your machines

Published in: Software
  • Be the first to comment

  • Be the first to like this

Ansible to provision your machines

  1. 1. Fellipe Callegas
  2. 2. × Software Developer at × Overwatch Player × Science Enthusiast × Center-forward Ronaldo’s Style Fellipe Callegas
  3. 3. What’re we going to talk about ❏ What's Ansible? ❏ Structure ❏ How it works ❏ Case
  4. 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. 5. Structure ❏ Inventory ❏ Modules ❏ Tasks ❏ Playbooks
  6. 6. × FILES × HANDLERS × TASKS × TEMPLATES {{var}} × VARS
  7. 7. $ 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
  8. 8. # 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 }}
  9. 9. Thanks! Any questions? You can find me at: Github: callegas Linkedin: Fellipe Callegas Blog: callegasdev.wordpress.com

×