Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ansibleで3台のビルドサーバーを3分で構築した話 / Set up build serv...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
oohira
December 20, 2016
Programming
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ansibleで3台のビルドサーバーを3分で構築した話 / Set up build servers in 3 min by Ansible
oohira
December 20, 2016
Transcript
35 slides
Ansibleで 3台のビルドサーバーを 3分で構築した話 第8回ビアバッシュLT in なにわ弐 2016/12/20 oohira
きっかけ
3台がかりでもビルド間に合わん master slave 1 slave 2 slave 3
このままでは(私の立場が) まずい…
_人人人人人人_ > 金の弾丸 <  ̄Y^Y^Y^Y^Y ̄
検証機用の余剰VM 3台をさらに投入する
3台も設定するの面倒だな… そのうちまた増えるんでしょ…
None
・サーバー構築を自動化するツール (構成管理ツールというジャンル) ・エージェントレスで対象サーバーに SSH接続して諸々の設定を反映する Ansibleとは master master master SSH
最小構成
管理対象のホストを定義したINIファイル $ cat hosts [build] 192.168.74.140 192.168.74.141 192.168.74.142 inventory
実行する手順をまとめたYAMLファイル $ cat playbook.yml - hosts: build user: root tasks:
- name: test connection ping: playbook
実行 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]
******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [test connection] ********************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.141 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.142 : ok=2 changed=0 unreachable=0 failed=0
モジュール
tasks: - name: Copy motd to remote copy: src: ./files/motd
dest: /etc/motd copy
tasks: - name: Install Git yum: name: git state: present
- name: Add symbolic link for Git file: src: /usr/bin/git dest: /usr/local/bin/git state: link force: yes yum, file
tasks: - name: Add rsadmin user user: name: rsadmin uid:
5004 password: "{{'hoge'|password_hash('sha512')}}" state: present user
tasks: - name: Install Oracle JDK unarchive: src: ./file/jdk-8u45-linux-x64.tar.gz dest:
/usr/java creates: /usr/java/jdk1.8.0_45 - name: Update alternative JDK alternatives: name: java link: /usr/bin/java path: /usr/java/jdk1.8.0_45/bin/java unarchive, alternative
つづきはWebで http://docs.ansible.com/ansible/list_of_all_modules.html
冪等性 (べきとうせい)
ある操作を1回実行しても 複数回実行しても同じ結果に なることを表す数学概念 ↓ 構成管理ツールを何回実行しても 同じサーバー状態に収束すること
$ cat playbook.yml - hosts: build user: root tasks: -
name: Install Git yum: name: git state: present yumの場合
実行1回目 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]
******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [Install Git] ************************************************************* changed: [192.168.74.140] changed: [192.168.74.141] changed: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0
実行2回目 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]
******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [Install Git] ************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0
Ansibleのメリット
・Excel手順書さようなら ・手動コストほぼゼロ ・人為的なミスほぼゼロ 1. 自動化
・途中で失敗しても何度でも実行 できる ・最終的にはあるべき状態に収束 している安心感 2. 冪等性
・インフラレベルも設定や手順、 変更履歴を見える化 ・インフラチームへの不必要な 設定確認の手間が減る ・開発とインフラが同じコードで 相互レビューして改善しやすい 3. Infrastructure as Code
話していないこと
・繰り返しや条件付き実行などのより 複雑な手順 ・playbookを分割管理するための ベストプラクティス ・秘密鍵など機密情報の管理方法 ・類似ツール(Chefとか)との比較 ・コンテナ技術との使い分け
まとめ
よさげ!
告知
Advent Calendarも大詰め!
おわり
More Decks by oohira
See All by oohira
git switch & git restore
oohira
0
150
私のエンジニア人生に影響を与えた技術書 / tech books that influenced my engineer life
oohira
1
310
コードレビューを通す技術 / technique to pass code review
oohira
1
140
Progressive OSS Contribution
oohira
1
190
Why Mob Programming?
oohira
3
2.5k
朝の15分読書会ふりかえり / 15min-reading-retrospective
oohira
0
190
朝の15分読書会のススメ
oohira
0
490
知っておくと便利なcurl
oohira
0
280
git-svnで始めるボッチのためのGit
oohira
0
5k
Other Decks in Programming
See All in Programming
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.8k
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
830
Modernizing iOS Apps
seyfoyun
0
150
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
100
Getting Started with Vibe Coding
miccheng
0
200
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
240
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
100
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
300
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
590
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
210
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
940
First, design no harm
axbom
PRO
2
1.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
Thoughts on Productivity
jonyablonski
76
5.5k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Evolving SEO for Evolving Search Engines
ryanjones
0
360
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
460
WCS-LA-2024
lcolladotor
0
990
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
620