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
俺流!!Ansible学習ベストプラクティス/ansible_for_beginners
Search
hiromaaa03
April 17, 2019
Technology
2
1.5k
俺流!!Ansible学習ベストプラクティス/ansible_for_beginners
2019/04/17 Ansible Night LT資料です
hiromaaa03
April 17, 2019
Tweet
Share
More Decks by hiromaaa03
See All by hiromaaa03
Infrastudy6
hiromaaa03
0
1k
CloudOperationsandTipsforNextGenerationMSPs
hiromaaa03
1
230
Other Decks in Technology
See All in Technology
ハッカソンから社内プロダクトへ AIエージェント ko☆shi 開発で学んだ4つの重要要素
leveragestech
0
550
I tried making a solo advent calendar!
zzzzico
0
130
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
1
150
テストセンター受験、オンライン受験、どっちなんだい?
yama3133
0
200
モノタロウ x クリエーションラインで実現する チームトポロジーにおける プラットフォームチーム・ ストリームアラインドチームの 効果的なコラボレーション
creationline
0
370
AWS re:Inventre:cap ~AmazonNova 2 Omniのワークショップを体験してきた~
nrinetcom
PRO
0
130
re:Invent2025 セッションレポ ~Spec-driven development with Kiro~
nrinetcom
PRO
2
170
産業的変化も組織的変化も乗り越えられるチームへの成長 〜チームの変化から見出す明るい未来〜
kakehashi
PRO
1
270
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
Bedrock AgentCore Evaluationsで学ぶLLM as a judge入門
shichijoyuhi
2
320
わが10年の叡智をぶつけたカオスなクラウドインフラが、なくなるということ。
sogaoh
PRO
1
200
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
The agentic SEO stack - context over prompts
schlessera
0
580
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
390
KATA
mclloyd
PRO
33
15k
AI: The stuff that nobody shows you
jnunemaker
PRO
1
150
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
120
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Designing for Performance
lara
610
70k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
84
Ruling the World: When Life Gets Gamed
codingconduct
0
120
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