Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
俺流!!Ansible学習ベストプラクティス/ansible_for_beginners
Search
hiromaaa03
April 17, 2019
Technology
1.5k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
俺流!!Ansible学習ベストプラクティス/ansible_for_beginners
2019/04/17 Ansible Night LT資料です
hiromaaa03
April 17, 2019
More Decks by hiromaaa03
See All by hiromaaa03
Infrastudy6
hiromaaa03
0
1.1k
CloudOperationsandTipsforNextGenerationMSPs
hiromaaa03
1
240
Other Decks in Technology
See All in Technology
『GOエコノミー 』(相乗りサービス) におけるスペック駆動開発
mot_techtalk
1
120
AIに会社の文脈を理解させる技術~上流工程・非エンジニアにも広げるハーネスエンジニアリング実践~
ochtum
0
200
The seven pitfalls of AI (revised version)
ufried
0
170
猫でもわかるKiro Web
kentapapa
1
160
PQC移行の今 -- IETF からみた現在地
satokan
4
720
企業の現実世界をグラフで写し取る
sansantech
PRO
0
230
Terraformを用いたJamf Pro構成のIaC, GitOps化への挑戦
yukun
0
120
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
300
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
220
2026-09-26 Platform Engineering Kaigi 2026 インフラとアプリの境界線と委譲の設計 / Drawing the Infra and App Line
masasuzu
0
540
AWS FinOps Agent 結局何が得意なの?
siromi
0
230
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.9k
Typedesign – Prime Four
hannesfritz
42
3.2k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
430
Rails Girls Zürich Keynote
gr2m
96
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
New Earth Scene 8
popppiees
4
2.6k
Ruling the World: When Life Gets Gamed
codingconduct
0
380
RailsConf 2023
tenderlove
30
1.6k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
260
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
850
Transcript
AXLBIT Inc. 0 俺流!! Ansible学習ベストプラクティス @hiromaaa03
AXLBIT Inc. 1 自己紹介 • 竹西 宏真(@hiromaaa03) • AXLBIT株式会社 •
ソリューション部 • インフラエンジニア • 趣味:バスケットボール、お酒 • コミュニティ活動:YOUTH TECH (@youthtechtokyo)
AXLBIT Inc. 2 やってること
AXLBIT Inc. 3 Built by 環境構築やってます。
AXLBIT Inc. 4 Released by リリースやってます。
AXLBIT Inc. 5 いま、おそらく社内で一番Playbookかいてます。
AXLBIT Inc. 6 もともと
AXLBIT Inc. 7 Ansible… なにそれ おいしいの?
AXLBIT Inc. 8 俺流!! 右も左もわからない新卒が実践した Ansible学習ベストプラクティス
AXLBIT Inc. 9 前提として • 自由につくってこわせる実行環境の用意 • Ansibleベストプラクティスを意識したシンプルなPlaybookの用意 https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout https://github.com/ansible/ansible-examples/tree/master/lamp_simple
AXLBIT Inc. 10 では本題
AXLBIT Inc. 11 といっても
AXLBIT Inc. 12 4つのSTEPを繰り返すだけ
AXLBIT Inc. 13 STEP 1 魔法のansible-playbookコマンド
AXLBIT Inc. 14 STEP 2 手動での環境構築
AXLBIT Inc. 15 STEP 3 手順書の作成
AXLBIT Inc. 16 STEP 4 Playbookの作成
AXLBIT Inc. 17 Playbook理解への道のり
AXLBIT Inc. 18 Inventory • 対象ホストをグループに分けてホスト制御を確認 • インベントリファイルになるべくvars(変数)を記述しない ※好みの問題だと思ってます。僕はなるべくvarsの記述場所を統一したい派
AXLBIT Inc. 19 group_vars • まずvars(変数)の定義はgroup_varsのみで確認 – なれてきたらinventoryやhost_vars,extra_varsをつかってみる! – 内容をリスト定義してみたりするとよりgood!!
• 優先順位を意識する https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html > 優先度:高 優先度:低 高 低
AXLBIT Inc. 20 task • taskには必ずnameをつける! • shellモジュールやcommandモジュールの使用を控える • 頻出モジュールを調査する(yum,template,files
などなど…) • 個人的には”when”による条件分岐にはやく慣れる https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#the-when-statement
AXLBIT Inc. 21 filesとtemplates(設定ファイルの送付) • filesとtemplatesの違いを認識する – 送付するファイルに変数を使用しない場合、rolesディレクトリ内files配下に ファイルを格納し、copyモジュールを使用 –
送付するファイルに変数を使用する場合 、rolesディレクトリ内templates配下に ファイルを格納し、templateモジュールを使用 ※ チームでPlaybookを編集する場合など、filesとtemplatesの構成を理解せずに Playbookの編集をすると上記をごちゃごちゃに配置する人が出てくる恐れがあるので チームへの周知もかねて徹底しましょう!! (ちなみに実際にありました。。。)
AXLBIT Inc. 22 jinja2 • 便利!!だから使おう!!! https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html http://jinja.pocoo.org/docs/2.10/ • Templateで設定ファイルを送付するときに柔軟な設定が可能
– 設定ファイル内でif分岐やforによるループ処理、varsに格納している変数の反映など • taskでも使用可能。 – 取得したvarsの配列からフィルターをかけて対象の要素のみを取り出せる – whenの判定にも使用可能など ※Jinja2テンプレート自体のバージョンによって使えるフィルターなどに違いがあるので注意
AXLBIT Inc. 23 ありがとうございました。
AXLBIT Inc. 24 AXLBITブログ立ち上げようとしてます。 まだ準備中なのでミラーサイトですが、Ansibleの多重ループについて記事を書きました。 良ければ、ご覧ください!! https://blog.axltest.biz/?p=40
AXLBIT Inc. 25 Accelerate your Business with IT