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活用術
tomfook
3
1k
AWS Systems Managerのハイブリッドアクティベーションを使用したガバメントクラウド環境の統合管理
toru_kubota
1
180
AIエージェント時代に必要な オペレーションマネージャーのロールとは
kentarofujii
0
160
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
240
AgentCoreとLINEを使った飲食店おすすめアプリを作ってみた
yakumo
2
260
脳が溶けた話 / Melted Brain
keisuke69
1
1.1k
GitHub Actions侵害 — 相次ぐ事例を振り返り、次なる脅威に備える
flatt_security
8
4.9k
Phase07_実務適用
overflowinc
0
2.1k
イベントで大活躍する電子ペーパー名札を作る(その2) 〜 M5PaperとM5PaperS3 〜 / IoTLT @ JLCPCB オープンハードカンファレンス
you
PRO
0
210
QA組織のAI戦略とAIテスト設計システムAITASの実践
sansantech
PRO
1
210
昔話で振り返るAWSの歩み ~S3誕生から20年、クラウドはどう進化したのか~
nrinetcom
PRO
0
100
Amazon Qはアマコネで頑張っています〜 Amazon Q in Connectについて〜
yama3133
1
150
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
250
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
330
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.1k
Building Adaptive Systems
keathley
44
3k
ラッコキーワード サービス紹介資料
rakko
1
2.8M
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
280
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