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
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
More Decks by oohira
See All by oohira
git switch & git restore
oohira
0
140
私のエンジニア人生に影響を与えた技術書 / tech books that influenced my engineer life
oohira
1
310
コードレビューを通す技術 / technique to pass code review
oohira
1
140
Progressive OSS Contribution
oohira
1
180
Why Mob Programming?
oohira
3
2.5k
朝の15分読書会ふりかえり / 15min-reading-retrospective
oohira
0
180
朝の15分読書会のススメ
oohira
0
490
知っておくと便利なcurl
oohira
0
280
git-svnで始めるボッチのためのGit
oohira
0
5k
Other Decks in Programming
See All in Programming
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
340
AWSに止められる覚悟してますか?
morizo_1984
2
490
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
340
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
250
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
5.3k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
330
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
200
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
290
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
710
Utilizing Notion as your number one productivity tool
mfonobong
4
600
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Side Projects
sachag
456
43k
Designing for humans not robots
tammielis
254
26k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
590
Facilitating Awesome Meetings
lara
57
7.2k
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も大詰め!
おわり