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で3台のビルドサーバーを3分で構築した話 / Set up build serv...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
oohira
December 20, 2016
Programming
240
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
More Decks by oohira
See All by oohira
git switch & git restore
oohira
0
130
私のエンジニア人生に影響を与えた技術書 / tech books that influenced my engineer life
oohira
1
300
コードレビューを通す技術 / technique to pass code review
oohira
1
130
Progressive OSS Contribution
oohira
1
170
Why Mob Programming?
oohira
3
2.4k
朝の15分読書会ふりかえり / 15min-reading-retrospective
oohira
0
180
朝の15分読書会のススメ
oohira
0
480
知っておくと便利なcurl
oohira
0
270
git-svnで始めるボッチのためのGit
oohira
0
4.9k
Other Decks in Programming
See All in Programming
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.5k
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
210
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
210
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
130
AIで効率化できた業務・日常
ochtum
0
150
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
610
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
240
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.4k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
どこまでゆるくて許されるのか
tk3fftk
0
260
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
640
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
YesSQL, Process and Tooling at Scale
rocio
174
15k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
How to build a perfect <img>
jonoalderson
1
5.7k
Un-Boring Meetings
codingconduct
0
320
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Transcript
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も大詰め!
おわり