狠狠撸

狠狠撸Share a Scribd company logo
Ansible
Claire Chang
础苍蝉颈产濒别免费版
付费版
Mac安裝?方式1-brew
https://hvops.com/articles/ansible-mac-osx/
惭补肠安装?方式1-辫颈辫
安装好的资料夹?目录
Ansible的設定
https://raw.githubusercontent.com/ansible/ansible/
devel/examples/ansible.cfg
ansible
Inventory?文件
主機清單,可以設定主機的相關資訊
將遠端主機分組,並在裡?面設定要連接的參參數
ansible
Ansible的指令
檢查ansible的安裝環境
ansible -m ping
複製檔案/etc/hosr到遠端主機組Web,位置為/
tmp/hosts
ansible web -m copy -a “src=/etc/hosts dest=/
tmp/hosts”
?用Playbook管理理主機
包含了了關鍵字有hosts(主機組名或主機IP), remote_user(以某個使?用者
?身份執?行行), vars(變數),tasks(要執?行行的指令,為playbook的核?心)
常?用的模組有yum, copy, template等
格式為YAML,可以?用JSON去線上轉
http://www.json2yaml.com/
常?用模組
偵錯和測試類別
ping:看有沒連線成功
ansible services –m ping
debug:印簡單訊息
檔案類別模組
copy:複製檔案到遠端節點
template:從本機複製檔案並進?行行變數取代
file:設定檔案屬性
Linux上常?用操作
user:管理理使?用者帳?戶
yum:套件管理理指令
service:管理理服務
firewalld:管理理防火牆和通訊埠
執?行行shell指令
shell:在節點上執?行行shell
coommand:在遠端節點執?行行指令
觀察遠端主機系統變數
Setup: ansible –m setup
线上转换闯厂翱狈和驰础惭尝
Handlers
?自訂變數
事件處理理
Playbook的基本語法
主機資訊: hosts
?用那個此?用者?身份執?行行: users
執?行行的?工作內容(由上到下執?行行): tasks
執?行行完後要做的事: handlers
Ansible Role
Ansible 提供了了我們在撰寫?自動化腳本時?一
個?角?色 (role) 的概念念。我們可以透過撰寫屬
於?自?己的 role 來來讓所有 playbook 重複使
?用,藉此提升透過Ansible ?自動化的靈活度。
Role檔案位置 Role檔案內容 在腳本內呼叫roles的指令
Ad

Recommended

Ansible 101
Ansible 101
YI-CHING WU
?
現代 IT 人一定要知道的 Ansible 自動化組態技巧
現代 IT 人一定要知道的 Ansible 自動化組態技巧
Chu-Siang Lai
?
Automate with Ansible basic (3/e)
Automate with Ansible basic (3/e)
Chu-Siang Lai
?
Continuous Delivery Workshop with Ansible x GitLab CI (2nd)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd)
Chu-Siang Lai
?
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)
Chu-Siang Lai
?
Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)
Chu-Siang Lai
?
Continuous Delivery Workshop with Ansible x GitLab CI
Continuous Delivery Workshop with Ansible x GitLab CI
Chu-Siang Lai
?
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
Chu-Siang Lai
?
我们要做什麼」20230707
我们要做什麼」20230707
Claire Chang
?
笔颈虫颈.箩蝉网页游戏开发实战
笔颈虫颈.箩蝉网页游戏开发实战
Claire Chang
?
骋颈迟版本管理控管实战
骋颈迟版本管理控管实战
Claire Chang
?
萨提尔的对话练习
萨提尔的对话练习
Claire Chang
?
从零架设直播伺服器
从零架设直播伺服器
Claire Chang
?
Learn to code 2 - Beyond the Basics
Learn to code 2 - Beyond the Basics
Claire Chang
?
Ane
Ane
Claire Chang
?
Starling
Starling
Claire Chang
?
Auto layout in i os 7
Auto layout in i os 7
Claire Chang
?

More Related Content

More from Claire Chang (9)

我们要做什麼」20230707
我们要做什麼」20230707
Claire Chang
?
笔颈虫颈.箩蝉网页游戏开发实战
笔颈虫颈.箩蝉网页游戏开发实战
Claire Chang
?
骋颈迟版本管理控管实战
骋颈迟版本管理控管实战
Claire Chang
?
萨提尔的对话练习
萨提尔的对话练习
Claire Chang
?
从零架设直播伺服器
从零架设直播伺服器
Claire Chang
?
Learn to code 2 - Beyond the Basics
Learn to code 2 - Beyond the Basics
Claire Chang
?
Ane
Ane
Claire Chang
?
Starling
Starling
Claire Chang
?
Auto layout in i os 7
Auto layout in i os 7
Claire Chang
?
我们要做什麼」20230707
我们要做什麼」20230707
Claire Chang
?
笔颈虫颈.箩蝉网页游戏开发实战
笔颈虫颈.箩蝉网页游戏开发实战
Claire Chang
?
骋颈迟版本管理控管实战
骋颈迟版本管理控管实战
Claire Chang
?
萨提尔的对话练习
萨提尔的对话练习
Claire Chang
?
从零架设直播伺服器
从零架设直播伺服器
Claire Chang
?
Learn to code 2 - Beyond the Basics
Learn to code 2 - Beyond the Basics
Claire Chang
?
Auto layout in i os 7
Auto layout in i os 7
Claire Chang
?

ansible