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モジュール自作入門
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
satoken
October 28, 2018
590
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ansibleモジュール自作入門
satoken
October 28, 2018
More Decks by satoken
See All by satoken
やる夫Ansible.pdf
satoken
1
510
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
30 Presentation Tips
portentint
PRO
1
430
Crafting Experiences
bethany
1
380
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
480
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Transcript
hcmD([. Ansible 自作入門
Ansible ? - Introduction: - Pythonで実装されたインフラ構成管理ツール - サーバ、DB、NW、クラウド etc -
2.7.0では2900モジュールもあるそうな - Red Hat, Debian, CentOS, OS X, any of the BSDsで動作
ラズパイで動く んじゃね?
None
動いた!
最初にやるのは もちろん
Lチカ
_人人人人人人人人人人人_ > AnsibleでGPIO操作 <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄
どうやって?
ソースを読んでみる
Ansibleモジュール完全に理解した - 1モジュール、1つのファイルで構成 yumモジュール → yum.py - 実際の処理 開始: AnsibleModuleでPlaybookからパラメータを受け取る
途中: 必要な処理を行う→コマンド打ったりAPI呼んだり 終了: module.exit_json()を呼んで終了 - 開始と終了のお作法を守れば途中の処理は何してもいいのでは
数を足して返すだけ
こんな感じ
動作が理解できた ので
Lチカでけた
指定したピンと回数でLチカする gpio: setup: "OUT" pin: 18 count: 5 →GPIOモジュールを呼ぶだけ →使い道?
調子に乗って量産
小型液晶に出力
SSD1306に文字を出す SSD1306: disp_str: "ラズパイでAnsible動いた!“ →Adafruitのsampleをそのまま流用 →使い道?
BME280モジュール
BME280で温度・湿度・気圧 bme280: bus: 1 i2c_addr: 0x76 →スイッチサイエンスのsampleをそのまま流用 →使い道?
factsで値を返す
赤外線LEDで扇風機を操作
単純にON/OFFするだけ senpuuki: power_state: on →irsendコマンドをmodule.run_command()に渡してるだけ →使い道?
扇風機の状態を変えるためちゃんと changed: trueを返す
まとめ - raspberry pi に Ansible を入れることで Python、Ansibleだけでなく電子工作の知識も一通り学べる。 →Ansibleモジュールを作るために回路図を見る こういう楽しみ方もいいのではないでしょうか!
× アイディアは無限大