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
AnsibleWorkshopMay2019.pdf
Search
Andreas Mosti
May 14, 2019
Programming
0
250
AnsibleWorkshopMay2019.pdf
https://dipsas.github.io/AnsibleCourse/
Andreas Mosti
May 14, 2019
Tweet
Share
More Decks by Andreas Mosti
See All by Andreas Mosti
Deterministic Builds and where to find them
andmos
0
45
Correct Maps Are Useless: A guide to mental models
andmos
0
160
LEGO I Praksis
andmos
0
64
Supply Chain Attacks: Når den digitale forsyningslinja blir angrepsvektor
andmos
0
34
IoIT: Internet of Insecure Things
andmos
0
120
Containers'n stuff
andmos
0
39
IoT - Bevisstgjøring
andmos
0
45
GitOps in a nutshell
andmos
0
200
Supply Chain Attack
andmos
0
52
Other Decks in Programming
See All in Programming
Atomics APIを知る / Understanding Atomics API
ssssota
1
220
Nitro v3
kazupon
2
330
Level up your Gemini CLI - D&D Style!
palladius
1
130
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
500
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
32
15k
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
11
3.6k
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
310
AIを駆使して新しい技術を効率的に理解する方法
nogu66
1
660
生成AIを活用したリファクタリング実践 ~コードスメルをなくすためのアプローチ
raedion
0
150
Phronetic Team with AI - Agile Japan 2025 closing
hiranabe
2
680
CloudflareのSandbox SDKを試してみた
syumai
0
180
アーキテクチャと考える迷子にならない開発者テスト
irof
9
3.4k
Featured
See All Featured
Bash Introduction
62gerente
615
210k
Statistics for Hackers
jakevdp
799
230k
Making Projects Easy
brettharned
120
6.5k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Writing Fast Ruby
sferik
630
62k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
195
66k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
For a Future-Friendly Web
brad_frost
180
10k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
940
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Transcript
and infrastructure as code workshop Andreas Mosti
Key takeaways • Infrastructure as Code • Configuration Management •
What can Ansible solve? • What can it not solve? • Enough knowledge to understand the key principles
Dev/Build Runtime
Dev/Build Runtime
Dev/Build Runtime
Dev/Build Runtime
None
The complexity moves
None
None
Site A Site A Replica Site B Replica Site B
• Application platforms / runtimes • Permissions • Users •
Firewall rules • Config Files • Updates • Running Services • Upgrades
• Application platforms / runtimes • Permissions • Users •
Firewall rules • Config Files • Updates • Running Services • Upgrades 20
None
Inconsistent server farms
Platform requirements, «What are we releasing on?»
«We need new environments quickly, in a reproducible fashion»
Automate the infrastructure
Snowflake vs. Phoenix Servers
Infrastructure as code:
Reproducible Environments
Servers in version control
Configuration management
Explicit process
Safety!
Code Review
Baked vs. Fried servers
The usual suspects
None
None
Why Ansible?
None
None
Open Source
SSH WinRM
Most important:
The correct abstraction (for us)
None
Playbooks push Database Appserver Load Balancer
None
Remember: Ansible keeps state
The benefits of Infrastructure as Code: 1) Automation 2) Version
control 3) Code Review 4) Testing 5) Documentation 6) Reuse
The holy grale: Imutable infrastructure
Warning 1:
None
None
None
None
The files don’t represent reality!
None
Warning 2:
If not run often, the system might regress
Part 1: Inventory and connection
SSH WinRM
WinRM Port 5986 Local / AD admin user w. remoting
Powershell 3.0 ConfigureRemotingForAnsible.ps1
SSH Port 22 root / dedicated user(s)
None
None
The Inventory
inventory/Example.inventory
inventory/Testlab18.inventory
Exercise 1: Inventory and server connection
Part 2: Playbooks and tasks
Playbooks push Database Appserver Loadbalancer
LoadBalancer.yaml Zookeeper.yaml Solr.yaml Database.yaml ArenaAppServer.yaml
WebServer.yaml
WebServer.yaml
WebServer.yaml
WebServer.yaml
roles/DotNet461/tasks/main.yaml
None
None
Exercise 2: Playbook and simple tasks
Part 3: Roles and variables
WebServer.yaml
To reuse tasks or implement components, we make roles
Example roles: • IIS • DotnetFramework45 • Oracle12C • TeamcityAgent
• Java • GoogleChrome • SplunkForwarder
None
Buildserver.yaml
roles/Oracle12Driver/tasks/main.yaml
roles/Oracle12Driver/tasks/main.yaml
roles/Oracle12Driver/defaults/main.yaml
Lists and iterators
roles/Zookeeper/tasks/main.yaml roles/Zookeeper/defaults/main.yaml
A word on variable precendence
From least to most important: • role defaults • group_vars/
• host_vars/ • host facts • play vars • include_vars • set_facts • extra vars
A word on state and idempotency
Always pick modules over shell commands (if possible)
roles/MKDocs/tasks/main.yaml
roles/MKDocs/tasks/main.yaml
Exercise 3: Roles, variables and iterators
Part 4: Handlers, templates, files
None
Files vs Templates
roles/TeamCityAgent/tasks/main.yaml
True configuration management with templating and JINJA2
roles/TeamCityAgent/templates/buildAgent.properties
roles/SplunkForwarder/templates/input.conf.j2
roles/HAProxy/templates/haproxy.conf.j2
roles/Prometheus/templates/alertmanager.yml.j2
roles/Prometheus/defaults/main.yml
roles/TeamCityAgent/tasks/main.yaml
roles/TeamCityAgent/handlers/main.yaml
Exercise 4: Templates, handlers and files
Part 5: Ansible Vault
When working with secrets roles/TeamCityAgent/tasks/main.yaml
roles/TeamCityAgent/defaults/main.yaml
None
roles/TeamCityAgent/defaults/main.yaml
None
roles/TeamCityAgent/defaults/main.yaml
Exercise 5: Vault and encryptet secrets