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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
airhand
February 27, 2018
Technology
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ansible入門
ansibleの概要説明とサンプルリポジトリのリンク
airhand
February 27, 2018
More Decks by airhand
See All by airhand
JS Framework入門(2018)
airhand
0
81
Docker 入門
airhand
0
100
Other Decks in Technology
See All in Technology
サイバー捜査員研修(前半)
nomizone
1
2k
AWS ネットワーク構築でハマった(ハマりかけた) 5選とそこから得た教訓
nagisa53
4
240
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
Sets in Go
ramalho
1
860
ブラウザ研修 2026
recruitengineers
PRO
6
1.1k
2026-08-15 JAWS-UG 茨城 #16 Secrets ManagerにおけるSecret値の管理(Terraformの場合) / Secrets Manager Secrets
masasuzu
0
130
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.4k
My broken English still works: speaking at global OSS events
naruoga
0
110
【CEDEC2026】『GRANBLUE FANTASY: Relink - Endless Ragnarok』のバトル制作事例 ~最高のキャラゲーを目指して~
cygames
PRO
1
310
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
140
20分でわかるセキュアAPI
nwiizo
2
290
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
210
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
530
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
73
41k
A Tale of Four Properties
chriscoyier
163
24k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Into the Great Unknown - MozCon
thekraken
41
2.7k
WENDY [Excerpt]
tessaabrams
11
39k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
4 Signs Your Business is Dying
shpigford
187
23k
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