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
250
勝手にAlibaba Cloud White Beltシリーズ Elastic Compute Service(ECS)/alieaters-20190301
morita92hiro
0
400
希望のRancher〜コンテナをアウフヘーベン〜/ranchermeetup-20171006
morita92hiro
0
280
いまからDockerで始めるGitLab CE/gitlabjp-20170919
morita92hiro
1
1.4k
月額10円から作るServerless Website〜Azure編〜/serverlessfukuoka-20170825
morita92hiro
8
17k
コンテナ運用いきのこるには/ranchermeetup-20170807
morita92hiro
1
570
AWS Summit Tokyoをお探しですか?/jawsug-20170713
morita92hiro
0
170
ブラウザだけでインフラ操作?〜これさえあれば、何もいらない。〜/fukuazu-20170622
morita92hiro
1
900
Other Decks in Technology
See All in Technology
Kubeshark で Kubernetes の Traffic を眺めてみよう/Let's Look at k8s Traffic with Kubeshark
kota2and3kan
3
370
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
520
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
150
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
.NET 9 のパフォーマンス改善
nenonaninu
0
360
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
830
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
100
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Become a Pro
speakerdeck
PRO
26
5k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
160
4 Signs Your Business is Dying
shpigford
181
21k
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