SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Michal Haták
AUTOMATION FOR EVERYONE
Michal Haták
• INIZIO Internet Media
• Python / PHP / JS / AWS
• @Twistacz
• github.com/Twista
Automation
• Minimize or reduce human intervention
• Faster
• Less error prone
• Reproducible
Shell scripts ?
• Hard to write
• Hard to maintain
• Error prone
Ansible ?
• Configuration Management
• Application Deployment
• Multi-Tier Orchestration
Why Ansible ?
• Agent-less (just SSH)
• Easy
• YAML - no coding required
• Modules
Concept
• Inventories
• Modules
• Plays and Playbooks
• Tasks
• Facts and Variables
• Templates
• Roles
# inventory.ini
[webserver]
wpweekend ansible_host=10.88.88.10
[localws]
local ansible_connection=local
Inventory - list of machines / groups
The super-power of Modules
Cloud

Clustering

Commands

Database

Files

Inventory

Messaging

Monitoring
Network

Notification

Packaging

Source Control

System

Utilities

Web Infrastructure

Windows
# main.yml
- name: task name
module_name:
param_name_1 = param_value_1
- name: task 2 name
module_name: param1 = val1 param2 = val2
Playbooks and Plays
# main.yml
- name: download and extract WordPress
unarchive:
src=http://wordpress.org/wordpress-{{ wp_version }}.tar.gz
dest={{ target_directory }}
copy=no
creates={{ target_directory }}/wordpress
Playbooks and Plays
# main.yml
- name: create WordPress database
mysql_db: name={{ wp_db_name }} state=present
- name: create WordPress database user
mysql_user:
name={{ wp_db_user }}
password={{ wp_db_password }}
priv={{ wp_db_name }}.*:ALL
host='localhost'
state=present
Playbooks and Plays
- name: change SSH port
hosts: aws_launched
tasks:
- name: SSH port in configuration is 12345
replace:
dest=/etc/ssh/sshd_config
regexp='^Port 22$'
replace='Port 12345'
backup=yes
become: True
tags: ssh
- name: SSH service restarted
service: name=ssh state=restarted
become: True
tags: ssh
Playbooks and Plays
- name: bower package
npm: state=present global=yes name=bower
- name: bower packages
bower: path={{ install_dir }}/app/static
sudo: no
tags: deploy
Playbooks and Plays
- name: git installed
apt: state=present name=git
- name: clone destination exists
file: state=directory path={{ install_directory }}
- name: repository is at given tag/commit or latest master
git: repo={{ repository_url }}.git
dest={{ install_directory }}
version={{ version }}
tags: deploy
Playbooks and Plays
- name: system packages present
apt: state=present name={{ item }}
with_items:
- python-dev
- python-pip
- python-lxml
Playbooks and Plays
Facts and Variables
• Work with machine data (hostname, ip, OS, devices)
• Custom variables to re-use roles and playbooks
# group_vars/all
target_directory: /tmp/wpweekend
wp_version: 4.5.2
# These are the WordPress database settings
wp_db_name: wordpress
wp_db_user: wordpress
wp_db_password: secret
Facts and Variables
# templates/wp-config.php.j2
<?php
define('DB_NAME', '{{ wp_db_name }}');
define('DB_USER', '{{ wp_db_user }}');
define('DB_PASSWORD', '{{ wp_db_password }}');
...
{{ wp_salt.stdout }}
....
Templates
.
└── my-role
├── README.md
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
└── main.yml
Roles
Demo
Links
• docs.ansible.com
• https://medium.com/@Twistacz
• http://www.root.cz/serialy/konfiguracni-a-orchestracni-nastroj-
ansible/
Thanks!
Questions ?

Contenu connexe

Tendances

Tendances (20)

ansible why ?
ansible why ?ansible why ?
ansible why ?
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with Terraform
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshop
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Advance discussion on Ansible - Rahul Inti
Advance discussion on Ansible - Rahul IntiAdvance discussion on Ansible - Rahul Inti
Advance discussion on Ansible - Rahul Inti
 
Automating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWSAutomating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWS
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with Ansible
 
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
 

En vedette

Debugování s XDebug
Debugování s XDebugDebugování s XDebug
Debugování s XDebug
Taste Medio
 

En vedette (13)

Validating XML - Avoiding the pain
Validating XML - Avoiding the painValidating XML - Avoiding the pain
Validating XML - Avoiding the pain
 
Debugování s XDebug
Debugování s XDebugDebugování s XDebug
Debugování s XDebug
 
Profiling PHP Applications
Profiling PHP ApplicationsProfiling PHP Applications
Profiling PHP Applications
 
What makes a good developer from a management perspective
What makes a good developer from a management perspectiveWhat makes a good developer from a management perspective
What makes a good developer from a management perspective
 
Martin Froněk - Jak využít soft skills ve svůj prospěch 2 (15. sraz přátel PH...
Martin Froněk - Jak využít soft skills ve svůj prospěch 2 (15. sraz přátel PH...Martin Froněk - Jak využít soft skills ve svůj prospěch 2 (15. sraz přátel PH...
Martin Froněk - Jak využít soft skills ve svůj prospěch 2 (15. sraz přátel PH...
 
Čtvrtkon #44 - Symfony php framework
Čtvrtkon #44 - Symfony php frameworkČtvrtkon #44 - Symfony php framework
Čtvrtkon #44 - Symfony php framework
 
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clustercommit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
 
Symfony vs Nette vs Phalcon
Symfony vs Nette vs PhalconSymfony vs Nette vs Phalcon
Symfony vs Nette vs Phalcon
 
Microservice Stategies - Scaling your API design workflow
Microservice Stategies - Scaling your API design workflowMicroservice Stategies - Scaling your API design workflow
Microservice Stategies - Scaling your API design workflow
 
Moje první aplikace v Symfony 3 + překvapení (4. sraz přátel Symfony v Praze)
Moje první aplikace v Symfony 3 + překvapení (4. sraz přátel Symfony v Praze)Moje první aplikace v Symfony 3 + překvapení (4. sraz přátel Symfony v Praze)
Moje první aplikace v Symfony 3 + překvapení (4. sraz přátel Symfony v Praze)
 
FTP deployment Devel 2015
FTP deployment Devel 2015FTP deployment Devel 2015
FTP deployment Devel 2015
 
A Beginners Guide to noSQL
A Beginners Guide to noSQLA Beginners Guide to noSQL
A Beginners Guide to noSQL
 
Dealing with Enterprise Level Data
Dealing with Enterprise Level DataDealing with Enterprise Level Data
Dealing with Enterprise Level Data
 

Similaire à Ansible

PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
grim_radical
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag
garrett honeycutt
 

Similaire à Ansible (20)

A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
Managing Infrastructure as Code
Managing Infrastructure as CodeManaging Infrastructure as Code
Managing Infrastructure as Code
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
Ansible at work
Ansible at workAnsible at work
Ansible at work
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
 
Functional Hostnames and Why they are Bad
Functional Hostnames and Why they are BadFunctional Hostnames and Why they are Bad
Functional Hostnames and Why they are Bad
 
Puppet
PuppetPuppet
Puppet
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Linux Desktop Automation
Linux Desktop AutomationLinux Desktop Automation
Linux Desktop Automation
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Ansible

  • 2. Michal Haták • INIZIO Internet Media • Python / PHP / JS / AWS • @Twistacz • github.com/Twista
  • 3. Automation • Minimize or reduce human intervention • Faster • Less error prone • Reproducible
  • 4. Shell scripts ? • Hard to write • Hard to maintain • Error prone
  • 5. Ansible ? • Configuration Management • Application Deployment • Multi-Tier Orchestration
  • 6. Why Ansible ? • Agent-less (just SSH) • Easy • YAML - no coding required • Modules
  • 7. Concept • Inventories • Modules • Plays and Playbooks • Tasks • Facts and Variables • Templates • Roles
  • 8. # inventory.ini [webserver] wpweekend ansible_host=10.88.88.10 [localws] local ansible_connection=local Inventory - list of machines / groups
  • 9. The super-power of Modules Cloud
 Clustering
 Commands
 Database
 Files
 Inventory
 Messaging
 Monitoring Network
 Notification
 Packaging
 Source Control
 System
 Utilities
 Web Infrastructure
 Windows
  • 10. # main.yml - name: task name module_name: param_name_1 = param_value_1 - name: task 2 name module_name: param1 = val1 param2 = val2 Playbooks and Plays
  • 11. # main.yml - name: download and extract WordPress unarchive: src=http://wordpress.org/wordpress-{{ wp_version }}.tar.gz dest={{ target_directory }} copy=no creates={{ target_directory }}/wordpress Playbooks and Plays
  • 12. # main.yml - name: create WordPress database mysql_db: name={{ wp_db_name }} state=present - name: create WordPress database user mysql_user: name={{ wp_db_user }} password={{ wp_db_password }} priv={{ wp_db_name }}.*:ALL host='localhost' state=present Playbooks and Plays
  • 13. - name: change SSH port hosts: aws_launched tasks: - name: SSH port in configuration is 12345 replace: dest=/etc/ssh/sshd_config regexp='^Port 22$' replace='Port 12345' backup=yes become: True tags: ssh - name: SSH service restarted service: name=ssh state=restarted become: True tags: ssh Playbooks and Plays
  • 14. - name: bower package npm: state=present global=yes name=bower - name: bower packages bower: path={{ install_dir }}/app/static sudo: no tags: deploy Playbooks and Plays
  • 15. - name: git installed apt: state=present name=git - name: clone destination exists file: state=directory path={{ install_directory }} - name: repository is at given tag/commit or latest master git: repo={{ repository_url }}.git dest={{ install_directory }} version={{ version }} tags: deploy Playbooks and Plays
  • 16. - name: system packages present apt: state=present name={{ item }} with_items: - python-dev - python-pip - python-lxml Playbooks and Plays
  • 17. Facts and Variables • Work with machine data (hostname, ip, OS, devices) • Custom variables to re-use roles and playbooks
  • 18. # group_vars/all target_directory: /tmp/wpweekend wp_version: 4.5.2 # These are the WordPress database settings wp_db_name: wordpress wp_db_user: wordpress wp_db_password: secret Facts and Variables
  • 19. # templates/wp-config.php.j2 <?php define('DB_NAME', '{{ wp_db_name }}'); define('DB_USER', '{{ wp_db_user }}'); define('DB_PASSWORD', '{{ wp_db_password }}'); ... {{ wp_salt.stdout }} .... Templates
  • 20. . └── my-role ├── README.md ├── defaults │   └── main.yml ├── files ├── handlers │   └── main.yml ├── meta │   └── main.yml ├── tasks │   └── main.yml ├── templates ├── tests │   ├── inventory │   └── test.yml └── vars └── main.yml Roles
  • 21. Demo
  • 22. Links • docs.ansible.com • https://medium.com/@Twistacz • http://www.root.cz/serialy/konfiguracni-a-orchestracni-nastroj- ansible/