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 + GitLab で楽に何度もデプロイする話 #ゆるWeb札幌
Search
Kihara, Takuya
PRO
February 15, 2020
Technology
2
500
Ansible + GitLab で楽に何度もデプロイする話 #ゆるWeb札幌
ゆるWeb勉強会@札幌 #8 (中止)
https://mild-web-sap.connpass.com/event/164107/
勉強会を中止にしたので、資料のみ。
Kihara, Takuya
PRO
February 15, 2020
Tweet
Share
More Decks by Kihara, Takuya
See All by Kihara, Takuya
ゆるWeb勉強会@札幌 #28 #ゆるWeb札幌
tacck
PRO
0
26
AWS Amplify の AI Kit でオレオレAIサイトを作ってみる #ゆるWeb札幌
tacck
PRO
0
33
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
490
Amplify Gen2 Deep Dive / How to convey backend types to the frontend #30DaysOfAmplify
tacck
PRO
0
21
TypeScript 雰囲気勢がライブラリのコードリーディングで得た知識 #sacss
tacck
PRO
1
50
ライブコーディングで知るAmplify Gen 2 #AWSAmplifyJP
tacck
PRO
1
140
AWS Amplify Gen 2 GA記念 ~Gen1との違いを確認
tacck
PRO
0
420
Amplify Gen2 が GA したよ! #jawsug_sapporo #jawsug
tacck
PRO
0
360
Flutter で "Hello World!! #ゆるWeb札幌
tacck
PRO
0
140
Other Decks in Technology
See All in Technology
組み込みアプリパフォーマンス格闘記 検索画面編
wataruhigasi
1
140
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
180
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
290
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
240
Qiita埋め込み用スライド
naoki_0531
0
5.3k
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
320
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
380
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
290
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
1
270
Wantedly での Datadog 活用事例
bgpat
2
690
普通のエンジニアがLaravelコアチームメンバーになるまで
avosalmon
0
120
JVM(JavaVM)の性能分析者観点で探るInstanaの可能性
instanautsjp
0
120
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1031
460k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
110
Build your cross-platform service in a week with App Engine
jlugia
229
18k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Docker and Python
trallard
42
3.1k
Faster Mobile Websites
deanohume
305
30k
How to Ace a Technical Interview
jacobian
276
23k
Documentation Writing (for coders)
carmenintech
67
4.5k
Transcript
גࣜձࣾϊʔεσΟςʔϧ ։ൃ%JWJTJPOٕज़ਪਐ(SPVQ UBDDLݪ !UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMF (JU-BCͰ ָʹԿσϓϩΠ͢Δ ݄
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • ໊લ ݪ / @tacck •
ॴଐ גࣜձࣾϊʔεσΟςʔϧ ։ൃDivision ٕज़ਪਐGroup / Leader • ओ࠵ • ΏΔWebษڧձ@ࡳຈ • εϚʔτεϐʔΧʔͰ༡΅͏ձ@ࡳຈ • ͖ͳϑΟΪϡΞεέʔτͷٕ εϓϨουɾΠʔάϧ ୭ PHP Conference Hokkaido 2019
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Ansible • GitLab CI/CD • ࿈ܞͯ͠ԿΛ͔ͬͨ
ࠓ͢͜ͱ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ ͦͦ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • ࣾͷҊ݅ͰɺαʔόʔҠ͕ඞཁͩͬͨɻ • খنͷอक • ͋Δاۀ͚εϚʔτϑΥϯΞϓϦͷ ༻αʔό
(ΦϯϓϨ) • ࣾͷϚγϯཧʹ͍ɺAWS Lightsail Ҡɻ • ϑΝΠϧͷஔɺ֬ೝ߲ͳͲ͢Ͱʹݻ·͍ͬͯΔͷͰɺ εϜʔζʹ࡞ۀ͢ΔͨΊɻ ͦͦ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Ҋ݅ಛ༗ͷߏͳͲɺʮҰճʯΕجຊऴΘΓɻ → ࣗಈԽͳͲ͢ΔίετΛ͑ͳ͍ɻ • ͱݴ͍ͭͭɺ͜͏͍͏খنҊ݅ ʮ୲ऀʯͷೖΕସΘΓ͕ൃੜ͍͢͠ɻ
(ͦͷ࣌ʹରԠͰ͖Δਓ͕ରԠ͢ΔɺɺͳͲɻ) ͱ͍͑
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Ansible ʹΑΔΠϯϑϥͷίʔυԽ (IaaC) • GitLab CI/CD
ʹΑΔσϓϩΠͷࣗಈԽ (DevOps) • ࠓޙΛݟਾ͓͖͔͑ͯͬͯͨͬͨɻ • ίʔυԽ͓ͯ͘͠ͱࣾͷݟల։͍͢͠ͷͰɺ ৭ʑͱʹཱͭɻ ͦͷͨΊ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMFͱ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMF https://www.ansible.com/
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMFͷಛ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Python • ΤʔδΣϯτϨε • ૢ࡞ରʹɺಛผͳԿ͔ΛೖΕͳͯ͘ྑ͍ɻ
( SSH ͱ Python ͕͋Εྑ͍ɻ) • YAML • ઃఆYAMLͰهड़Մೳɻ • ઃఆͷه๏ͦͷͷͷशಘқ͍ɻ (͍͍ͨػೳ͝ͱʹ֮͑Δ͜ͱɺͪΖΜ͋Γ·͢ɻ) "OTJCMFͷಛ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Ϟδϡʔϧ • ϞδϡʔϧํࣜͰɺػೳ֦ு͞Ε͍ͯΔɻ • ඞཁͳΒɺࣗͰ࡞Մೳɻ •
ຊମ Python ͕ͩɺ Ϟδϡʔϧ Python ͡Όͳͯ͘OKɻ "OTJCMFͷಛ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • ႈੑ • ʮԿ࣮ߦͯ͠ಉ͡ঢ়ଶʹͳΔʯ͜ͱΛαϙʔτɻ • ͨͩ͠ɺϞδϡʔϧͷ࣮࣍ୈɻ •
ϑΝΠϧஔαʔϏεΠϯετʔϧͱ͍ͬͨͷɺ جຊతʹαϙʔτ͞Ε͍ͯΔɻ • ʮίϚϯυ࣮ߦʯܥͷϞδϡʔϧɺ αϙʔτ͞Ε͍ͯͳ͍Մೳੑ͕͋ΔͷͰҙɻ (Ansible ͔ΒݟͯอূͰ͖ͳ͍ͷͰɻ) "OTJCMFͷಛ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMFͷྺ࢙
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • 2012ʹ “Ansible, Inc.” ͕։ൃ։࢝ɻ • 2013ʹ
ࢲ͍࢝Ίͨ (Β͍͠) ɻ https://qiita.com/tacck/items/e3669b94e6a8066ce642 • ͜ͷ࣌ظߏཧπʔϧͷོظɻ • “Chef” ͕ڧ͔ͬͨهԱɻ (Ruby) • 2015ʹ Red Hat ࣾʹΑΓങऩɻ • ͪͳΈʹɺ Red Hat ࣾ 2018ʹ IBM ࣾʹΑΓങऩɻ "OTJCMFͷྺ࢙
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ "OTJCMFઃఆͷجຊ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • ରͱͳΔϗετͷใ (Inventory) • INIܗࣜ or YAMLܗࣜ
(ൺֱత࠷ۙରԠ͞Εͨ) • աڈͷใΛάάΔͱɺINIܗࣜͷใ͕ͨ͘͞Μɻ • ૢ࡞༰ (Playbook) • ػೳ୯ҐͰׂ͢Δ Roles ܗࣜͰॻ͘ͷ͕Ұൠతɻ "OTJCMFઃఆͷجຊ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ *OWFOUPSZ [web] 192.168.100.1 [web:vars] ansible_port=22 ansible_user=centos ansible_ssh_private_key_file=hosts/testing/web_testing.pem
[all:vars] stage=testing
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ 1MBZCPPL NBJOZNM --- - hosts: all become:
yes vars_files: - "vars/{{ stage }}.yml" roles: - setups - file_upload
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ 1MBZCPPL SPMFTTFUVQTUBTLTNBJOZNM --- - name: set timezon
Asia/Tokyo shell: timedatectl set-timezone Asia/Tokyo - name: install httpd yum: name: httpd state: latest - name: enable httpd systemd: name: httpd enabled: yes - name: restart httpd systemd: name: httpd state: restarted
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ 1MBZCPPL SPMFTpMF@VQMPBEUBTLTNBJOZNM --- - name: upload index.html
file template: src: index.html.j2 dest: "/var/www/html/index.html"
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ (JU-BC$*$%ͱ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • GitHub Έ͍ͨͳ Git Repository αʔϏεɻ •
ͦͷதͷػೳͱͯ͠ɺ “CI/CD” ͕͋Δɻ • ϦϙδτϦʹ͋ΔίʔυΛͬͯɺ ৭ʑ͍͍ͬͯΑ! ͱ͍͏αʔϏεɻ (JU-BC
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • ઃఆΛ YAML Ͱهड़ɻ • ίʔυͷνΣοΫɺϑϩϯτΤϯυͷϏϧυɺ αʔόʔͷσϓϩΠͳͲͳͲΛهड़Մೳɻ
• ઃఆهड़ޙɺ git push ͢ΔͨͼʹࣗಈͰ࣮ߦ͞ΕΔɻ • खಈͰͷ࣮ߦɾ࠶࣮ߦՄೳɻ (JU-BC$*$%
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ (JU-BC$*$% HJUMBCDJZNMൈਮ stages: - deploy - testing
.deploy_job: &deploy_job stage: deploy image: cytopia/ansible:2.9-tools script: - ansible-playbook -i hosts/${APP_ENV}/inventory main.yml deploy testing: <<: *deploy_job variables: APP_ENV: testing before_script: - chmod 755 . - cat $SSH_KEY_PEM > hosts/testing/web_testing.pem - chmod 600 hosts/testing/web_testing.pem
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ σϞ -JHIUTBJMͰαʔό४උ *OWFOUPSZʹ*1ࢦఆ (JU-BC$*$%ͰσϓϩΠ IUUQTHJUIVCDPNUBDDLTBNQMFBOTJCMFNJMEXFCTBQ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ ·ͱΊ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • Ansible ΛͬͯΠϯϑϥ (αʔόͷߏ) ΛίʔυԽɻ • ίʔυʹͳ͍ͬͯΕɺσϓϩΠࣗಈԽՄೳɻ
(GitLab CI/CD) • σϓϩΠࣗಈԽ͞Ε͍ͯΕɺ ͙͢ʹ҆ఆͨ͠ڥΛखʹೖΕΒΕΔ!! • ςετͩͬͯॻ͚ͪΌ͏!!! • ಈ͘ͷΛఏࣔͰ͖ΔͷͰɺਓʹ͍͑͢ɻ ·ͱΊ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ FOE
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ ࡳຈͷΠϯϑϥɾΫϥυܥ ษڧձͷҊ ൺֱత׆ಈ͍ͯ͠Δͷ ࢲ͕ิͰ͖ͨͷ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • https://jawsug-sapporo.doorkeeper.jp/events/102248 • ࡾʙ࢛ϲ݄ʹҰճఔ • ࣍ճ: 20202݄21(ۚ)
+"846(ࡳຈ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • https://sapporo-aws.connpass.com/event/163725/ • ࡾʙ࢛ϲ݄ʹҰճఔ 4BQQPSPBXT
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • https://sapporoazuremok2.connpass.com/event/154302/ • ຖ݄Ұճ • ࣍ճ: 20202݄22
() ࡳຈ"[VSF͘͘ձ
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • https://sapporo-beginner-kubernetes.connpass.com/event/ 161411/ • ࡾϲ݄ʹҰճఔ ,VCFSOFUFT4BQQPSPGPS#FHJOOFST
!UBDDL ΏΔ8FCษڧձ!ࡳຈ ΏΔ8FCࡳຈ • https://ansible-users.connpass.com/event/159174/ • ·ͩҰճͰ͕͢ɺࠓճͬͨͷͰɻ • ࢲࢀՃͯ͠LT͠·ͨ͠ɻ "OTJCMF͘͘ձ
αʔόฤ JOࡳຈ