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入門
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
75
Docker 入門
airhand
0
94
Other Decks in Technology
See All in Technology
強化されたAmazon Location Serviceによる新機能と開発者体験
dayjournal
4
280
PHPでWebブラウザのレンダリングエンジンを実装する
dip_tech
PRO
0
220
AI導入の理想と現実~コストと浸透〜
oprstchn
0
160
mrubyと micro-ROSが繋ぐロボットの世界
kishima
3
390
FOSS4G 2025 KANSAI QGISで点群データをいろいろしてみた
kou_kita
0
320
Backlog ユーザー棚卸しRTA、多分これが一番早いと思います
__allllllllez__
1
110
生まれ変わった AWS Security Hub (Preview) を紹介 #reInforce_osaka / reInforce New Security Hub
masahirokawahara
0
380
Should Our Project Join the CNCF? (Japanese Recap)
whywaita
PRO
0
300
KubeCon + CloudNativeCon Japan 2025 に行ってきた! & containerd の新機能紹介
honahuku
0
120
ビズリーチが挑む メトリクスを活用した技術的負債の解消 / dev-productivity-con2025
visional_engineering_and_design
1
3.1k
OPENLOGI Company Profile for engineer
hr01
1
33k
事業成長の裏側:エンジニア組織と開発生産性の進化 / 20250703 Rinto Ikenoue
shift_evolve
PRO
2
9.4k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
810
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Testing 201, or: Great Expectations
jmmastey
42
7.6k
Designing Experiences People Love
moore
142
24k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
Designing for humans not robots
tammielis
253
25k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Adopting Sorbet at Scale
ufuk
77
9.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
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