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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
78
Docker 入門
airhand
0
99
Other Decks in Technology
See All in Technology
OpenShiftでllm-dを動かそう!
jpishikawa
0
100
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
230
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
5.4k
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
410
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
140
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.5k
Tebiki Engineering Team Deck
tebiki
0
24k
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
350
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.8k
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
240
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
WENDY [Excerpt]
tessaabrams
9
36k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
320
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
350
How to train your dragon (web standard)
notwaldorf
97
6.5k
Context Engineering - Making Every Token Count
addyosmani
9
650
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
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