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
450
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
Learning Lab: WordPress
erikaheidi
0
71
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
140
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
180
Automatizando documentação em PHP com Autodocs
erikaheidi
0
130
Building the World: The Story Behind Wolfi
erikaheidi
0
720
Hello Wolfi
erikaheidi
1
730
Container Images for the Cloud Native Era
erikaheidi
1
390
Creating Secure Container Images with apko
erikaheidi
0
550
Criando GitHub Actions em PHP com Minicli
erikaheidi
0
240
Other Decks in Programming
See All in Programming
C++20 射影変換
faithandbrave
0
540
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
440
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
110
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.4k
都市をデータで見るってこういうこと PLATEAU属性情報入門
nokonoko1203
1
570
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
1
120
NPOでのDevinの活用
codeforeveryone
0
370
XP, Testing and ninja testing
m_seki
3
200
Gleamという選択肢
comamoca
6
760
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
140
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Cult of Friendly URLs
andyhume
79
6.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Facilitating Awesome Meetings
lara
54
6.4k
Rails Girls Zürich Keynote
gr2m
94
14k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Automating Front-end Workflow
addyosmani
1370
200k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
Code Review Best Practice
trishagee
68
18k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
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