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
480
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Automation made simple with Ansible
As presented at Cloudconf 2015 in Turin, Italy
Erika Heidi
March 19, 2015
More Decks by Erika Heidi
See All by Erika Heidi
FreeCAD 101 Lightning Talk
erikaheidi
0
68
Learning Lab: WordPress
erikaheidi
0
150
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
220
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
280
Automatizando documentação em PHP com Autodocs
erikaheidi
0
210
Building the World: The Story Behind Wolfi
erikaheidi
0
860
Hello Wolfi
erikaheidi
1
820
Container Images for the Cloud Native Era
erikaheidi
1
480
Creating Secure Container Images with apko
erikaheidi
0
680
Other Decks in Programming
See All in Programming
OSもどきOS
arkw
0
590
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
210
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
さぁV100、メモリをお食べ・・・
nilpe
0
150
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
300
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
120
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.5k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
A2UI という光を覗いてみる
satohjohn
1
150
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
120
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
How to make the Groovebox
asonas
2
2.2k
The Cost Of JavaScript in 2023
addyosmani
55
10k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
730
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
200
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Google's AI Overviews - The New Search
badams
0
1k
How STYLIGHT went responsive
nonsquared
100
6.2k
A better future with KSS
kneath
240
18k
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