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
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
470
Amplify Gen2 Deep Dive / How to convey backend types to the frontend #30DaysOfAmplify
tacck
PRO
0
18
TypeScript 雰囲気勢がライブラリのコードリーディングで得た知識 #sacss
tacck
PRO
1
45
ライブコーディングで知るAmplify Gen 2 #AWSAmplifyJP
tacck
PRO
1
130
AWS Amplify Gen 2 GA記念 ~Gen1との違いを確認
tacck
PRO
0
380
Amplify Gen2 が GA したよ! #jawsug_sapporo #jawsug
tacck
PRO
0
350
Flutter で "Hello World!! #ゆるWeb札幌
tacck
PRO
0
140
AWS Lambda で LLRT を動かしてみた #北海道まったりLT大会
tacck
PRO
0
150
地方から始める登壇のステップアップ 〜Java Do から JJUG CCC への登壇参加記録 #javado
tacck
PRO
0
210
Other Decks in Technology
See All in Technology
まだチケットを手動で書いてるの?!GitHub Actionsと生成AIでチケットの作成を自動化してみた話 / 20241207 Yoshinori Katayama
shift_evolve
1
820
新機能Amazon GuardDuty Extended Threat Detectionはネ申って話
cmusudakeisuke
0
330
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
1
110
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
130
OpsJAWS32 re:Invent 2024 Ops系アップデートまとめ
takahirohori
0
110
アジャイルテストの4象限で考える プロダクト開発の品質への向き合い方
nagano
1
980
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
2
1.2k
WernerVogelsのKeynoteで語られた6つの教訓とOps
hatahata021
1
200
イノベーショントークから見るクラウド運用の未来を振り返ってみた
nyankotaro
0
410
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
120
テーブルが200以上あるSaaSでRSCとGraphQLを併用する理由
msickpaler
1
800
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
1
140
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
160
A better future with KSS
kneath
238
17k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Practical Orchestrator
shlominoach
186
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
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ࡳຈ