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
78
Docker 入門
airhand
0
99
Other Decks in Technology
See All in Technology
(Test) ai-meetup slide creation
oikon48
1
290
Claude Codeの進化と各機能の活かし方
oikon48
22
12k
ナレッジワーク IT情報系キャリア研究セッション資料(情報処理学会 第88回全国大会 )
kworkdev
PRO
0
170
SRE NEXT 2026 CfP レビュアーが語る聞きたくなるプロポーザルとは?
yutakawasaki0911
1
250
Claude Code Skills 勉強会 (DevelersIO向けに調整済み) / claude code skills for devio
masahirokawahara
1
16k
モブプログラミング再入門 ー 基本から見直す、AI時代のチーム開発の選択肢 ー / A Re-introduction of Mob Programming
takaking22
5
1.3k
The_Evolution_of_Bits_AI_SRE.pdf
nulabinc
PRO
0
130
マルチプレーンGPUネットワークを実現するシャッフルアーキテクチャの整理と考察
markunet
2
240
OCI Security サービス 概要
oracle4engineer
PRO
2
13k
ナレッジワークのご紹介(第88回情報処理学会 )
kworkdev
PRO
0
180
「ストレッチゾーンに挑戦し続ける」ことって難しくないですか? メンバーの持続的成長を支えるEMの環境設計
sansantech
PRO
3
650
20260311 技術SWG活動報告(デジタルアイデンティティ人材育成推進WG Ph2 活動報告会)
oidfj
0
290
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
Un-Boring Meetings
codingconduct
0
220
GitHub's CSS Performance
jonrohan
1032
470k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
We Have a Design System, Now What?
morganepeng
55
8k
How to train your dragon (web standard)
notwaldorf
97
6.6k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
30 Presentation Tips
portentint
PRO
1
250
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
190
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
470
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
250
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