Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ansible 介紹
Search
williamwu
April 18, 2014
Technology
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ansible 介紹
如何使用 Ansible 管理大量機器
williamwu
April 18, 2014
Transcript
24 slides
Ansible 簡介 吳佳寰 <
[email protected]
>
⾃自我揭露 • ⾃自由軟體愛好者 • 對於技術某些時候有點偏執 • 不認同請忽略,我講的也不⼀一定是對的
阿宅的⼀一天 • 修電腦 • 維護作業系統(安裝、升級) • 維護網站(安裝、升級) • 維護網路 •
資訊教學(推展、課程) • 設備採購
本次討論範圍 • 修電腦 • 維護作業系統(安裝、升級) • 維護網站(安裝、升級) • 維護網路 •
資訊教學(推展、課程) • 設備採購
分析⽇日常⼯工作 • 維護系統 • 安裝(耗時、⾮非急迫、重要) • 升級(耗時、急迫、重要) • 備份(不耗時、⾮非急迫、重要) •
還原(不耗時、急迫、重要)
分析⽇日常⼯工作 • 維護網站 • 安裝(耗時、⾮非急迫、重要) • 升級(耗時、急迫、重要、複雜) • 備份(不耗時、⾮非急迫、重要) •
還原(不耗時、急迫、重要)
如何減輕⼯工作負擔 1. ⾃自動化 2. ⾃自動化 3. ⾃自動化 4. ⾃自動化 5.
⾃自動化 6. ⾃自動化
Ansible是... • Configuration Management Software • 組態管理軟體 • 這可以吃嗎?
先不要管Ansible了,你 聽過安麗shell scripts嗎
⼈人⼯工安裝版 <安裝apache2> 1. ssh <yourname>@<remote_host> 2. sudo aptitude update &&
sudo aptitude install apache2 -y 3. <wait and see> 4. exit
半⾃自動安裝版 <安裝apache2> 1. <寫好script> 2. scp your_scripts.sh <your_name>@<remote_host> 3. ssh
<your_name>@<remote_host> 4. sudo ./your_script.sh 5. <wait and see> 6. exit
your_script.sh sudo aptitude update if [ ! $? -eq 0
]; then echo "Update error" exit 1 fi sudo aptitude install apache2 -y if [ ! $? -eq 0 ]; then echo "Install Apache2 error" exit 2 fi echo "Install completed."
Ansible版<安裝apache2> install_apache2.yml --- - hosts: all sudo: yes tasks: -
name: install apache2 apt: pkg=apache2 update_cache=yes
Ansible版 執⾏行安裝任務 • ansible-playbook install_apache2.yml • 結束
Live Demo <更新所有系統⾄至最新版>
安裝Ansible The Hard Way • aptitude update • aptitude install
python-dev python-virtualenv python-pip -y • virtualenv myvenv • source myvenv/bin/activate • pip install ansible
定義 /etc/ansible/hosts localhost ansible_connection=local [webservers] 192.168.1.1 192.168.1.2 [dnsservers] 192.168.1.3 192.168.1.4
使⽤用 ansible執⾏行簡單指令 ansible all —ask-pass —sudo -m shell -a “aptitude
update” ansible webservers —ask-pass —sudo -m shell -a “aptitude install apache2 -y” ansible dnsservers —sudo -m shell -a “reboot”
學會ansible命令 就可以上⼯工了 等你習慣了再來玩 playbook
Ansible Playbook 撰寫 yaml 檔案組織任務
playbook 範例 —- - hosts: all tasks: - name: run
my own script script: runmyscript.sh - name: reboot the system shell: reboot
更多進階討論請加⼊入 irc.freenode.net #osatfe
FAQ • Q: 所以學會了Ansible,就可以不⽤用懂shell script 是嗎? • Q: 所以學了Ansible,我就可以不⽤用懂套件管理 嗎?
• Q: 所以Ansible到底是要解決什麼問題?
Any questions?
Other Decks in Technology
See All in Technology
gem install とrequire のむこうがわ
ydah
0
130
Sonnetだけで業務はまわる?
kintotechdev
1
140
Skill とカスタムエージェント (手順と役割を渡す) | 目指せ Kiro マスター 08
inariku
PRO
2
110
業務の傍らで進める改善ループエンジニアリング
bengo4com
0
110
パスワードのない鍵で、 データを手元に置く
ginjihayashi
0
190
DevOps Agentにあらゆるセキュリティインシデントのトリアージを任せた件
jirtosterone
1
170
仕様と現実の間で落とし所を探るリモートMCPの認証・認可 — Sansanの認証基盤における課題と実践
sansantech
PRO
2
330
Kiro CLI 入門 (ターミナルと CI で使う) | 目指せ Kiro マスター 03
inariku
PRO
2
170
Re:ゼロから始めるシェアハウスのペットな鯖
silmin_
0
170
並列度を下げたら速くなった — go build の重複コンパイルを実測で見る
tomoaki25
2
1.3k
個人ASを取得して、自宅Kubernetes上のVMをグローバルIPで公開した話
munenick
0
130
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
110
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.8k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
530
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
560
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Bash Introduction
62gerente
615
220k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
980
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
69k
The SEO Collaboration Effect
kristinabergwall1
1
620
Amusing Abliteration
ianozsvald
1
390