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.2k
決戦用MSセンチネル/alterbooth-20190606
morita92hiro
1
230
勝手に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
550
AWS Summit Tokyoをお探しですか?/jawsug-20170713
morita92hiro
0
160
ブラウザだけでインフラ操作?〜これさえあれば、何もいらない。〜/fukuazu-20170622
morita92hiro
1
890
Other Decks in Technology
See All in Technology
ラブグラフ紹介資料 〜プロダクト解体新書〜 / Lovegraph Product Deck
lovegraph
0
14k
【インフラエンジニアbooks】30分でわかる「AWS継続的セキュリティ実践ガイド」
hssh2_bin
4
1.7k
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
1.4k
エムスリー全チーム紹介資料 / Introduction of M3 All Teams
m3_engineering
1
320
Kubernetes Meetup Tokyo #67 - KEP-3619: Fine-grained SupplementalGroups Control / k8sjp67-kep-3619
everpeace
0
130
【shownet.conf_】ShowNet伝送改めShowNet APN 2024
shownet
PRO
0
450
【㈱アイモバイル】エンジニア向け会社説明資料
imobile
0
470
入門 KRR
donkomura
0
110
Castor - Le Task Runner PHP qui simplifie votre Workflow
lyrixx
1
230
Webセキュリティのあるきかた
akiym
32
10k
Amazon ECS & AWS Fargate 今昔物語 / past and present stories of Amazon ECS and AWS Fargate
iselegant
2
200
怖くないオフライン機能開発 〜基本的な技術で実現する現場向けオフライン機能 / Developing offline functions without fear ~ Offline functions for the field realized with basic technology
kaminashi
0
110
Featured
See All Featured
Visualization
eitanlees
143
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Building an army of robots
kneath
302
42k
Happy Clients
brianwarren
97
6.7k
Code Reviewing Like a Champion
maltzj
519
39k
How to train your dragon (web standard)
notwaldorf
87
5.6k
How to name files
jennybc
77
99k
Statistics for Hackers
jakevdp
796
220k
KATA
mclloyd
27
13k
Building Adaptive Systems
keathley
38
2.2k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
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