Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ansible入門
Search
airhand
February 27, 2018
Technology
0
260
ansible入門
ansibleの概要説明とサンプルリポジトリのリンク
airhand
February 27, 2018
Tweet
Share
More Decks by airhand
See All by airhand
JS Framework入門(2018)
airhand
0
76
Docker 入門
airhand
0
97
Other Decks in Technology
See All in Technology
打 造 A I 驅 動 的 G i t H u b ⾃ 動 化 ⼯ 作 流 程
appleboy
0
140
手動から自動へ、そしてその先へ
moritamasami
0
290
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
110
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
[JAWS-UG 横浜支部 #91]DevOps Agent vs CloudWatch Investigations -比較と実践-
sh_fk2
1
240
エンジニアとPMのドメイン知識の溝をなくす、 AIネイティブな開発プロセス
applism118
4
1.1k
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
390
日本Rubyの会の構造と実行とあと何か / hokurikurk01
takahashim
4
960
Oracle Technology Night #95 GoldenGate 26ai の実装に迫る1
oracle4engineer
PRO
0
150
EM歴1年10ヶ月のぼくがぶち当たった苦悩とこれからへ向けて
maaaato
0
270
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
460
Playwright x GitHub Actionsで実現する「レビューしやすい」E2Eテストレポート
kinosuke01
0
470
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
How GitHub (no longer) Works
holman
316
140k
A Tale of Four Properties
chriscoyier
162
23k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Transcript
Ansible 構成管理ツール やり方次第でデプロイも可能 冪等性を持つ (一部モジュールを除く)
冪等性とは 数学において、冪等性(べきとうせい、英: idempotence 「巾等性」とも書くが読み方は同じ) は、 大雑把に言って、ある操作を1回行っ ても複数回行っても結果が同じである ことをいう概念である。 Wikipediaより
競合ツール
競合ツールとの違い プッシュ型でsshで接続するので、ノードにパッケ ージをインストールする必要がほぼない (Pythonが あればOK) YAMLを使うので比較的シンプル。Rubyを覚える 必要がなく、linuxコマンドがわかっていれば大体 読める(はず)
今までは... Load Balancer Web Server DB Server haproxy nginx httpd
MariaDB PostgreSQL 構成管理者 毎回手作業 手順が増えるたびにメモ ノードが増えると地獄 簡単なものはスクリプトにできるが、要求が増えるとメンテが大変
ansibleを導入すると... ansible Load Balancer Web Server DB Server Playbooks (YAML)
haproxy nginx httpd MariaDB PostgreSQL 構成管理者 playbookをバージョン管理 各ノードにsshでつなげるようにしておく 環境構築はコマンドを打つだけ ssh ssh ssh
nginx インストール & サービス開始 --- - hosts: web-servers tasks: -
name: install nginx yum: name: nginx state: installed - name: start nginx.service systemd: name: nginx state: started enabled: yes
基本はYAMLを書くだけ
学習コストを抑えられる
設定ファイルをテンプレートから生成 --- - hosts: web-servers tasks: - name: setup nginx
xxx.conf template: src: xxx.conf.j2 dest: /etc/nginx/conf.d/xxx.conf notify: restart nginx # 変更があれば再起動 - meta: flush_handlers handlers: - name: restart nginx systemd: name: nginix state: restarted
テンプレートの中身 jinja2 というテンプレートライブラリを利用 $ cat xxx.conf.j2 server { {# IPアドレス等をハードコードせずに変数で設定できる
#} server_name {{ hostvars[inventory_hostname]['ansible_eth ↓↓↓ $ cat /etc/nginx/conf.d/xxx.conf server { server_name 192.168.33.30;
実際は以下のような構成で運用 ├── ansible.cfg ├── inventories │ └── sample │ └──
hosts ├── playbooks │ ├── common.yml │ ├── db-servers.yml │ ├── roles │ │ ├── common │ │ ├── mariadb │ │ ├── nginx # roleそれぞれでtasks、handlersを管理 │ │ │ ├── handlers │ │ │ ├── tasks │ │ │ └── templates │ │ └── php │ └── web-servers.yml # web-server向けのroleをインポート ├── site.yml # roleをまとめたymlをさらにまとめる └── ssh_config
sample https://bitbucket.org/rshimada/ansible-tutorial