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でOrchestrationを体感しよう!
Search
Kei Iwasaki
October 20, 2013
Technology
860
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AnsibleでOrchestrationを体感しよう!
NODE-Setagaya#5 (
http://www.zusaar.com/event/1102005
) で使った資料です。
Kei Iwasaki
October 20, 2013
Transcript
19 slides
Ansible で Orchestration を ! 体感しよう NODE-Setagaya#5 2013.10 @laugh_k
最近話題の Ansible という ” ” いわゆる 構成管理 ツールを実際にさわってみて とりあえずみんなで !
!! ! 「おー すげー 」って言おうぜ という内容です 突っ込んだことはできないです 今回の NODE-Setagaya
Python 製の構成管理ツール おおまかには以下のような特徴がある。 • 作業対象は sshd のみ入っていればよく 特別なエージェントなどは必要ない ※ ただし
python-simplejson には依存している • Playbook と呼ばれる YAML 形式のファイルで 作業内容を記載しておくことができる • SSH コマンドのオプションを環境変数で渡せるため ssh_config を用いた多段 SSH も使える。 Ansible とは
というわけで !! さっそく試してみよう
1.環境の準備
1. 環境の準備 まずは Python の開発環境を整えます。 実は yum や apt でも入れることはできますが、
せっかくなのでこの機会に ! 以下のようなモダンな環境の整え方を抑えておきましょう • pyenv https://github.com/yyuu/pyenv 複数バージョンの Python をインストール、管理が可能。 • pyenv-virtualenv https://github.com/yyuu/pyenv-virtualenv virtualenv を pyenv 環境で使えるようにしたプラグイン。 アプリケーションごとにモジュールを管理することができる。
1. 環境の準備 1-1. pyenv, pyenv-virtualenv のインストール ※ Unix 系環境が前提 %
cd % git clone git://github.com/yyuu/pyenv.git .pyenv % cat >> ~/.bashrc << \EOF > > ## pyenv Configure > export PYENV_ROOT="$HOME/.pyenv" > export PATH="$PYENV_ROOT/bin:$PATH" > eval “$(pyenv init -)” > EOF % exec $SHELL
1. 環境の準備 1-1. pyenv, pyenv-virtualenv のインストール ※ Unix 系環境が前提 %
cd .pyenv/plugins % git clone git://github.com/yyuu/pyenv-virtualenv.git % pyenv rehash
1. 環境の準備 1-2. pyenv 経由で Python2.6 系最新のインストール ※ Unix 系環境が前提
※ ライブラリ足りないと怒られるかも .. % pyenv install -l % pyenv install 2.6.8 % pyenv rehash
1. 環境の準備 1-2. ansible 用の Python 環境を作成 ※ Unix 系環境が前提
% cd ## 本日の作業用ディレクトリ作成 % mkdir node-setagaya5 ## Ansible 用に 2.6 系で Python 環境を作成 % pyenv virtualenv 2.6.8 node-setagaya5 % cd node-setagaya5 ## 作業フォルダで今回作成した Python 環境を使うように設定 % pyenv local node-setagaya5 ## Ansible のインストール % pip install ansible
そろそろ VirtualBox テンプレート ! 配るよ
2 . コマンドラインで Ansible を試す
2 . コマンドラインで Ansible を試す 2-1. hosts ファイルの作成 作業対象を以下のような感じで定義しておく。 セクションを作るとグループとして扱うことができる。
hosts ファイルの中身 ↓ 詳しいパラメータは を参照 http://www.ansibleworks.com/docs/intro_inventory.html % cd ~/node-setagaya5 % vim hosts [localnet] node-setagaya5 ansible_ssh_host=192.168.10.10
2 . コマンドラインで Ansible を試す 2-1. 試しに ping を打ってみる ”
プログラミングで言う Hello World!!” ! 的なことをやってみましょう % ansible node-setagaya5 \ > -i hosts \ ## 利用する hosts ファイルを指定 > -u root \ ## SSH ログインで使用するユーザーを指定 > -m ping \ ## 利用する ansible モジュールを指定 > -k ## SSH ログインをする際にパスワードの入力を求める場合に指定 SSH password: node-setagaya5 | success >> { "changed": false, "ping": "pong" }
2 . コマンドラインで Ansible を試す 2-2. 試しに適当なコマンドを打ってみる ↓ 利用できるモジュールは を参照
http://www.ansibleworks.com/docs/modules.html % ansible node-setagaya5 \ > -k -i hosts -u root -m command \ > -a 'uname -n' ## リモート先で実行するコマンドを指定 SSH password: node-setagaya5 | success | rc=0 >> node-setagaya5
3 . Playbook を試す
3 . Playbook を試す 3-1. YAML ! 形式で以下のように作る 例 )
sapmle.yml ( あくまで雰囲気を掴むためのものなのでいろいろ不足しております ) Playbook ↓ のモジュール、書き方は を参照 http://www.ansibleworks.com/docs/playbooks.html --- - hosts : node-setagaya5 user : username sudo : yes vars : php_ver : 5.5 handlers : - name : PHP Compile script : install-PHP-{{ php_ver }}.sh task : - name : Install PHP Library yum : name=$items enablerepo=epel state=installed with_items : - libmcrypt - libmcrypt-devel notify : PHP Compile
3 . Playbook を試す 3-2. Playbook の内容を実行する Playbook ! を書いたら実行するのみ
## -C オプションで実際にジョブは実行されずに内容の確認ができる (dry_run) % ansible-playbook sample.yml -i hosts -k -C ## 実際に実行する。基本的なオプションの意味は ansible コマンドと同様 % ansible-playbook sample.yml -i hosts -k
では実際に Playbook ! を書いてみよう
More Decks by Kei Iwasaki
See All by Kei Iwasaki
ECS Scheduled Task 上の定期実行バッチを ecschedule で GitOps 化した話 / A story about a scheduled execution batch on the ECS Scheduled Task converted to GitOps with ecschedule
laughk
2
11k
Python と出会ったインフラエンジニアの話 / / The story of an infrastructure engineer who met Python
laughk
0
1.3k
MSPだってプロビジョンしたい!
laughk
1
5.6k
Cli mini Hack!#1 ~Terminalとの親睦を深めよう~
laughk
0
3k
Other Decks in Technology
See All in Technology
これからのデータエンジニアの役割について考える / Rethinking the Role of Data Engineers in the AI Era
okiyuki99
0
460
Datadog の権限統制 〜Org 統合に向けて調べた注意点 / JDDUG-Meetup_24
visional_engineering_and_design
1
110
AWSを利用する上で知っておきたい名前解決の話 2026
nagisa53
5
3.6k
evcc & Home Assistant
naltatis
0
670
セキュリティ専任チームなしで攻撃を先回りするSREが実践したSIEM on Amazon OpenSearch Service
cscengineer
PRO
1
860
小さなエージェントから始めてみよう!実践コンテキストエンジニアリング
iwamot
PRO
0
120
狙われているAPIの脆弱性!今こそ手をつけるべき根本的な対策とは?
nagix
0
130
自治体AIコンタクトセンター、何をどこに任せる?~Amazon Connect Customer +Amazon Bedrockの実践知~ / 20261107 Satoshi Torano
shift_evolve
PRO
1
130
2026-11-11 Tamachi.sre#7 PaCにインフラリソースの命を救われました。 / PaC saves the infra resource life
masasuzu
0
150
会社説明資料_最新版
demaecan
0
32k
生成AI時代のIAMのマニアックな話
takuros
6
3.2k
Sonnetだけで業務はまわる?
kintotechdev
1
110
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
3
940
Prompt Engineering for Job Search
mfonobong
0
580
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
900
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
610
A Soul's Torment
seathinner
9
3.9k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
How Software Deployment tools have changed in the past 20 years
geshan
3
35k
Paper Plane (Part 1)
katiecoart
PRO
3
12k
Test your architecture with Archunit
thirion
2
2.5k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k