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/ansiblejp-20180803
Search
Kunihiro Morita
August 03, 2018
Technology
2
2.6k
夏休みで差がつく!Ansible/ansiblejp-20180803
Ansible Night in Fukuoka 2018.08 の資料です。 #ansiblejp
https://ansible-users.connpass.com/event/93620/
Kunihiro Morita
August 03, 2018
Tweet
Share
More Decks by Kunihiro Morita
See All by Kunihiro Morita
絵で覚える AWS 全 (?) サービス入門 〜 できるAWSカルタ 〜/jawsug-20191019
morita92hiro
1
2.3k
決戦用MSセンチネル/alterbooth-20190606
morita92hiro
1
240
勝手にAlibaba Cloud White Beltシリーズ Elastic Compute Service(ECS)/alieaters-20190301
morita92hiro
0
390
希望のRancher〜コンテナをアウフヘーベン〜/ranchermeetup-20171006
morita92hiro
0
270
いまからDockerで始めるGitLab CE/gitlabjp-20170919
morita92hiro
1
1.3k
月額10円から作るServerless Website〜Azure編〜/serverlessfukuoka-20170825
morita92hiro
8
16k
コンテナ運用いきのこるには/ranchermeetup-20170807
morita92hiro
1
560
AWS Summit Tokyoをお探しですか?/jawsug-20170713
morita92hiro
0
160
ブラウザだけでインフラ操作?〜これさえあれば、何もいらない。〜/fukuazu-20170622
morita92hiro
1
900
Other Decks in Technology
See All in Technology
Platform Engineering for Software Developers and Architects
syntasso
1
490
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
120
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
840
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
120
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
530
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
3
1.3k
FOSS4G 2024 Japan コアデイ 一般発表25 PythonでPLATEAUのデータを手軽に扱ってみる
ra0kley
1
150
The Role of Developer Relations in AI Product Success.
giftojabu1
0
110
Lambdaと地方とコミュニティ
miu_crescent
2
350
AWS⼊社という選択肢、⾒えていますか
iwamot
2
1.1k
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
450
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
340
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
How GitHub (no longer) Works
holman
310
140k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Facilitating Awesome Meetings
lara
50
6.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Done Done
chrislema
181
16k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
830
Building Your Own Lightsaber
phodgson
103
6.1k
A designer walks into a library…
pauljervisheath
203
24k
Transcript
ՆٳΈͰ͕ࠩͭ͘ʂ Ansible #ansiblejp 2018/8/3 Ansible Night in Fukuoka 2018.08 1
ా༟ גࣜձࣾΦϧλʔϒʔε ιϦϡʔγϣϯΞʔΩςΫτ ΈࠐΈ → ΫϥυΠϯϑϥ @morita92hiro https://hawaku.hateblo.jp 2018/8/3 Ansible
Night in Fukuoka 2018.08 2
Ansibleపఈೖ ൃചதʂ 2018/8/3 Ansible Night in Fukuoka 2018.08 3
ͭ·Βͳ͍ੈք͔Βͬͱܹͷ͋ΔੈքมԽͤ͞Α͏ʂ ɹɹɹɹɹ 2018/8/3 Ansible Night in Fukuoka 2018.08 4
2018/8/3 Ansible Night in Fukuoka 2018.08 5
Ansibleͱ1 1 https://www.ansible.com/overview/it-automation 2018/8/3 Ansible Night in Fukuoka 2018.08 6
ΤʔδΣϯτϨεʹίʔ υͰߏཧ͢Δπʔϧ 2018/8/3 Ansible Night in Fukuoka 2018.08 7
ͳͥAnsibleΛ͍࢝Ί͔ͨʁ! 2018/8/3 Ansible Night in Fukuoka 2018.08 8
࡞ͷґཔΛड͚Δ 2018/8/3 Ansible Night in Fukuoka 2018.08 9
ࢁͷ࡞ͷґཔΛड͚Δ 2018/8/3 Ansible Night in Fukuoka 2018.08 10
• Ҋ݅͝ͱͷαʔόʔ • ։ൃɺຊ൪༻ • ෳߏங • ΫϥυʹΑΔαʔόʔͷ͍ࣺͯ • ӡ༻
͜Εશ෦1ਓͰɾɾɾʁ 2018/8/3 Ansible Night in Fukuoka 2018.08 11
Ͳ͏ͬͯࡹ͘ʁ 2018/8/3 Ansible Night in Fukuoka 2018.08 12
!ؒΛݺͿ ͔͠͠ɺॿ͚ɾɾɾ! 2018/8/3 Ansible Night in Fukuoka 2018.08 13
͕࣌ؒΜΔ 2018/8/3 Ansible Night in Fukuoka 2018.08 14
#͍͍͑ 2018/8/3 Ansible Night in Fukuoka 2018.08 15
Infrastructure as Code 2018/8/3 Ansible Night in Fukuoka 2018.08 16
ʊਓਓਓਓਓਓਓʊ ʼɹಇ͖ํվֵɹʻ ʉY^Y^Y^Y^Y^Yʉ 2018/8/3 Ansible Night in Fukuoka 2018.08 17
ߏཧπʔϧͳ͠ • खॱॻΛݩʹखಈͰઃఆ • खಈΦϖϛεͷՄೳੑ • खॱॻຊʹ࠷৽ʁ • ࢼ͞ΕΔهԱྗ •
ൿͷλϨ 2018/8/3 Ansible Night in Fukuoka 2018.08 18
ߏཧπʔϧ͋Γ • खॱΛίʔυͰهड़ • ίʔυΛ࣮ߦͯࣗ͠ಈͰઃఆ • ୭Ͱ࣮ߦͰ͖Δ • ίʔυ͕࠷৽ͷঢ়ଶ •
όʔδϣϯཧ(Git)ͯ͠ɺҎલͷঢ়ଶʹ͢ͷ؆୯ • Կ࣮ߦͯ͠ಉ͡ঢ়ଶʢႈੑʣ 2018/8/3 Ansible Night in Fukuoka 2018.08 19
͞Βʹ 2018/8/3 Ansible Night in Fukuoka 2018.08 20
ίʔυڞ௨Խ (Ansible Role) • ͍ͭΠϯετʔϧ(sysstat, git) • ֤छϛυϧΣΞ(Apache, MySQL) •
ΫϥυʹԠͨ͡ઃఆ(ϝϞϦΩϟογϡ) ͑͏΄ͲRoleࢿ࢈͕૿͑Δ 2018/8/3 Ansible Night in Fukuoka 2018.08 21
Let's Ansible 2018/8/3 Ansible Night in Fukuoka 2018.08 22
࠷ݶඞཁͳ • Python • AnsibleίϚϯυ • inventory • module •
playbook 2018/8/3 Ansible Night in Fukuoka 2018.08 23
AnsibleίϚϯυ Πϯετʔϧ $ pip install ansible 2018/8/3 Ansible Night in
Fukuoka 2018.08 24
inventory ࡞ۀରͱͳΔϗετΛهड़͢ΔϑΝΠϧ [web] 192.168.0.10 [db] 192.168.0.20 2018/8/3 Ansible Night in
Fukuoka 2018.08 25
module ΠϯετʔϧαʔϏεىಈͳͲίϚϯυͷ෦ • yum • service $ ansible -i hosts
web -m ping 192.168.0.10 | success >> { "changed": false, "ping": "pong" } 2018/8/3 Ansible Night in Fukuoka 2018.08 26
playbook ϞδϡʔϧΛ࣮࣮ͯ͠ߦ͢Δ෦ - hosts: web sudo: yes tasks: - name:
be sure httpd is installed yum: name=httpd state=installed - name: be sure httpd is running and enabled service: name=httpd state=running enabled=yes 2018/8/3 Ansible Night in Fukuoka 2018.08 27
playbook࣮ߦ $ ansible-playbook -i hosts simple.yml PLAY [web] ************************************************************ GATHERING
FACTS *************************************************************** ok: [192.168.0.10] TASK: [be sure httpd is installed] ******************************************** changed: [192.168.0.10] TASK: [be sure httpd is running and enabled] ********************************** changed: [192.168.0.10] PLAY RECAP ******************************************************************** 192.168.0.10 : ok=3 changed=2 unreachable=0 failed=0 2018/8/3 Ansible Night in Fukuoka 2018.08 28
ଞʹ • Ϋϥυ • Vagrant • Windows • git •
ωοτϫʔΫػث ͳͲͳͲ 2018/8/3 Ansible Night in Fukuoka 2018.08 29
AnsibleΛಋೖ͍ͯ͠ΔՕॴ • αʔόʔϓϩϏδϣχϯά • ΞϓϦέʔγϣϯσϓϩΠ Ϋϥυ෦AWS CloudFormationAzure ARM Templateɺ TerraformΛ͍ͬͯ·͢ɻ
2018/8/3 Ansible Night in Fukuoka 2018.08 30
Ansibleͷӡ༻ 2018/8/3 Ansible Night in Fukuoka 2018.08 31
ಈ࡞ڥ 2018/8/3 Ansible Night in Fukuoka 2018.08 32
Πϯετʔϧ؆୯ • yum install ansible • apt-get install ansible •
pip install ansible ͓Έͷํ๏Ͱ 2018/8/3 Ansible Night in Fukuoka 2018.08 33
όʔδϣϯͷΈ߹Θͤ • Python 2 (versions 2.6 or 2.7) • Python
3 (versions 3.5 and higher) • Ansible 1.x or 2.x • Playbook࡞࣌ͷAnsibleόʔδϣϯ 2018/8/3 Ansible Night in Fukuoka 2018.08 34
Ansibleઐ༻ಈ࡞ڥ͕͋Δ • ܧଓతʹϓϩϏδϣϯΠϯά͢ΔͨΊͷڥ͕͋Δ • όʔδϣϯݻఆ or ߹ΘͤΒΕΔ • Not ࠷৽͔͠Εͳ͍͕ಈ͘ʹࠔΒͳ͍
!όʔδϣϯճආͰ͖ͦ͏ 2018/8/3 Ansible Night in Fukuoka 2018.08 35
Ansibleಈ࡞ڥ͕ͳ͍ • ଞਓʹ࣮ߦͯ͠Β͍͍͚ͨͲಈ࡞ڥʁ • ୯ൃͷҊ݅ • ίϚϯυΞοϓσʔτޙͷPlaybookಈ͘ʁʢޙํޓʣ 2018/8/3 Ansible Night
in Fukuoka 2018.08 36
͍ͨ͜͠ͱ • ڥґଘ͔Βͷղ์ • ϙʔλϏϦςΟ 2018/8/3 Ansible Night in Fukuoka
2018.08 37
ίϯςφͰղܾͰ͖ͦ͏ 2018/8/3 Ansible Night in Fukuoka 2018.08 38
Docker • Dockerfile FROM python:3.6-onbuild CMD [ "ansible", "--version" ]
• requirements.txt ansible>=2.5.0,<2.6.0 • Docker Build docker build -t local/ansible:2.5 . 2018/8/3 Ansible Night in Fukuoka 2018.08 39
docker run $ docker run -it --rm \ -v $HOME/.ssh:/root/.ssh:ro
\ -v $PWD:/playbooks \ -w /playbooks \ hawaku/ansible:2.5 \ bash root@29867ac2540f:/playbooks# ansible -i hosts all -m ping 2018/8/3 Ansible Night in Fukuoka 2018.08 40
alias alias ansible_2.5='docker run -it --rm \ -v $HOME/.ssh:/root/.ssh:ro \
-v $PWD:/playbooks \ -w /playbooks \ hawaku/ansible:2.5 \ bash' $ ansible_2.5 root@29867ac2540f:/playbooks# ansible -i hosts all -m ping 2018/8/3 Ansible Night in Fukuoka 2018.08 41
͘͠ playbook ├── site.yml ├── Dockerfile ├── requirements.txt ├── inventories
└── roles PlaybookʹDockerfileஔ͍ͱ͘ 2018/8/3 Ansible Night in Fukuoka 2018.08 42
·ͱΊ 2018/8/3 Ansible Night in Fukuoka 2018.08 43
AnsibleಋೖͷޮՌ • Πϯϑϥͷߏஙʹֻ͕͔࣌ؒΔ • !ࣗಈԽͰߏங࣌ؒͷॖɾۭ͖࣌ؒ༗ޮ׆༻ • !ઃఆ࿙Εɾϛε͕ͳ࣭͕҆͘ఆ • ΠϯϑϥΤϯδχΞෆࡏͰͷΞϓϦέʔγϣϯσϓϩΠ 2018/8/3
Ansible Night in Fukuoka 2018.08 44
ఆ࣌ୀࣾ2 2 http://redhat.lookbookhq.com/jpansiblecomic 2018/8/3 Ansible Night in Fukuoka 2018.08 45
͓·͚ 2018/8/3 Ansible Night in Fukuoka 2018.08 46
ࠇ͍ը໘͖Ͱ͢ΑͶʁ 2018/8/3 Ansible Night in Fukuoka 2018.08 47
AWX 2018/8/3 Ansible Night in Fukuoka 2018.08 48
AWXͰͰ͖Δ͜ͱ • AnsibleίϚϯυͷGUI൛ • Ϣʔβʔೝূ • ϩʔϧཧ • ࣮ߦཤྺ •
Rest API ͳͲͳͲ 2018/8/3 Ansible Night in Fukuoka 2018.08 49
Azure Cloud Shell ϒϥβͰαʔόʔϨεͰAnsibleಈ͖·͢ 2018/8/3 Ansible Night in Fukuoka 2018.08
50
Azure × Ansible 2018/8/3 Ansible Night in Fukuoka 2018.08 51
͓ΘΓ 2018/8/3 Ansible Night in Fukuoka 2018.08 52