Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Automation made simple with Ansible
Search
Erika Heidi
March 19, 2015
Programming
3
430
Automation made simple with Ansible
As presented at Cloudconf 2015 in Turin, Italy
Erika Heidi
March 19, 2015
Tweet
Share
More Decks by Erika Heidi
See All by Erika Heidi
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
47
Automatizando documentação em PHP com Autodocs
erikaheidi
0
29
Building the World: The Story Behind Wolfi
erikaheidi
0
300
Hello Wolfi
erikaheidi
1
590
Container Images for the Cloud Native Era
erikaheidi
1
260
Creating Secure Container Images with apko
erikaheidi
0
380
Criando GitHub Actions em PHP com Minicli
erikaheidi
0
150
Building GitHub Actions in PHP with Minicli
erikaheidi
0
430
10 Code Search Tricks for Open Source
erikaheidi
2
200
Other Decks in Programming
See All in Programming
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
0
510
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
110
Hanami and htmx
bkuhlmann
0
200
Rails と人魚の話/rails-and-mermaid
sanfrecce_osaka
0
100
入門 AWS Amplify Gen2 / Introduction to AWS Amplify Gen2
genkiogasawara
1
330
コーンフレークから始める モデリング会話入門
ogurotakayuki
0
350
Ruby Function Composition
bkuhlmann
1
330
Elm Form Validation
bkuhlmann
0
510
Nealle_Autify_LT_Slide202403
nealle
0
170
Netty Chicago Java User Group 2024-04-17
sullis
0
170
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
23
15k
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.1k
Featured
See All Featured
Building Your Own Lightsaber
phodgson
99
5.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Optimizing for Happiness
mojombo
370
69k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Fantastic passwords and where to find them - at NoRuKo
philnash
37
2.5k
Atom: Resistance is Futile
akmur
259
25k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Transcript
None
whoami
What to expect from this talk 1. Ansible Overview 2.
Inventories and ad-hoc commands 3. Using Playbooks 4. Playbook crash-course
ANSIBLE OVERVIEW
Ansible Overview • Simple and Straightforward • Human-readable automation language
• Agentless - needs only SSH • Extensive list of built-in modules • Used by Twitter, Atlassian, EA, Spotify, even NASA!
Installation $ brew update $ brew install ansible $ sudo
apt-add-repository -y ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install -y ansible Detailed installation instructions: do.co/ansible-docs Mac OSX Ubuntu *Windows is not officially supported as controller machine.
Setting up SSH access • Servers should be accessible via
SSH using keypair authentication • It's recommended to have a user with sudo NOPASSWD permission to run the tasks in the server How to configure your SSH access for running Ansible: bit.ly/ansible-ssh
INVENTORIES & AD-HOC COMMANDS
Inventory file #/etc/ansible/hosts [webservers] erikaheidi.com dev-human.com [testservers] 178.62.192.53 95.85.35.248
ad-hoc commands $ ansible all -m ping $ ansible webservers
-a “php -v” $ ansible all -i staging -a “sudo apt-get update” ansible group [-i inventory] [-m module]
DEMO 1 Running ad-hoc commands
None
None
USING PLAYBOOKS
A Simple Playbook # playbook.yml --- - hosts: all sudo:
true tasks: - name: Update apt-cache apt: update_cache=yes - name: Install Nginx apt: pkg=nginx state=latest
Running playbooks $ ansible-playbook -i staging -l webservers playbook.yml $
ansible-playbook playbook.yml --list-hosts $ ansible-playbook playbook.yml --list-tasks ansible-playbook [-i inventory] [-l group] playbook.yml
DEMO 2 ansible-playbook
None
THE PLAYBOOK CRASH-COURSE
Variables --- - hosts: all sudo: yes vars: web_server: nginx
tasks: - name: Install {{ web_server }} apt: pkg={{ web_server }} state=latest
Variables (facts) • Information discovered from systems • Globally available
• Example: ansible_default_ipv4.address
Loops (with_items) tasks: - name: Install Packages apt: pkg={{ item
}} state=latest with_items: - nginx - php5-fpm - git
Loops (with_items) --- - hosts: all sudo: yes vars: sys_packages:
[ 'nginx', 'php5-fpm', 'git' ] tasks: - name: Install Packages apt: pkg={{ item }} state=latest with_items: sys_packages
Conditionals - name: "shutdown Debian flavored systems" command: /sbin/shutdown -t
now when: ansible_os_family == "Debian" - name: check if bar is defined fail: msg="This play requires 'bar'" when: bar is not defined
Templates <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot {{ doc_root }} <Directory
{{ doc_root }}> AllowOverride All Require all granted </Directory> </VirtualHost>
Templates - Usage - name: Change default apache vhost template:
src=templates/apache.tpl dest=/etc/apache2/sites-available/000-default.conf
Handlers (services) vars: - doc_root: /vagrant tasks: - name: Change
default apache vhost template: src=templates/apache.tpl dest=/etc/apache2/sites-available/000-default.conf notify: restart apache handlers: - name: restart apache service: name=apache2 state=restarted
WORKING WITH ROLES
Roles . ├── playbook.yml └── roles ├── init │ └──
tasks │ └── main.yml └── nginxphp ├── handlers │ └── main.yml ├── tasks │ └── main.yml └── templates └── vhost.tpl #playbook.yml --- - hosts: all sudo: true vars: doc_root: /vagrant/web roles: - init - nginxphp
RESOURCES
None
Using Phansible with remote servers: bit.ly/phansible-remote
Ansible Tutorials: http://do.co/ansible