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
950
CloudOperationsandTipsforNextGenerationMSPs
hiromaaa03
1
220
Other Decks in Technology
See All in Technology
Amazon Bedrockで実現する 新たな学習体験
kzkmaeda
1
520
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
180
GitHub Copilot の概要
tomokusaba
1
130
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
680
PostgreSQL 18 cancel request key長の変更とRailsへの関連
yahonda
0
120
Agentic DevOps時代の生存戦略
kkamegawa
1
1.3k
Кто отправит outbox? Валентин Удальцов, автор канала Пых
lamodatech
0
330
Node-RED × MCP 勉強会 vol.1
1ftseabass
PRO
0
140
Agentic Workflowという選択肢を考える
tkikuchi1002
1
490
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
16
5.4k
【TiDB GAME DAY 2025】Shadowverse: Worlds Beyond にみる TiDB 活用術
cygames
0
1k
CSS、JSをHTMLテンプレートにまとめるフロントエンド戦略
d120145
0
290
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
5
210
RailsConf 2023
tenderlove
30
1.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
33
5.9k
A Tale of Four Properties
chriscoyier
160
23k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
For a Future-Friendly Web
brad_frost
179
9.8k
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