4. MANAGEMENT COMPARE
Ansible Puppet Chef
Script Language YAML Custom DSL based on Ruby Ruby
Infrastructure
Controller machine applies
configuration on nodes via SSH
Puppet Master synchronizes
configuration on Puppet Nodes
Chef Workstations push configuration
to Chef Server, from which the Chef
Nodes will be updated
Requires specialized software
for nodes
No Yes Yes
Provides centralized point of
control
No. Any computer can be a controller Yes, via Puppet Master Yes, via Chef Server
12. ANSIBLE PLAYBOOK EXAMPLE
- - -
- name: test //此次playbook 執⾏行行描述
hosts: all //指定執⾏行行的host
vars: //變數宣告位置,與facts 不⼀一樣,此變數是所有host 共⽤用⼀一個,需注意
- hello: hello
tasks: //要執⾏行行的tasks 動作宣告,由上⽽而下依序執⾏行行
- debug: var=hello
notify:
- call in every action
handlers: //要執⾏行行的handler 動作宣告,觸發條件為task changed,同樣由上⽽而下依序
執⾏行行
- name: call in every action
debug: msg=“call in every action, but execute only one time”
13. ANSIBLE ROLE STRUCTURE
Roles
├── common
│ ├── defaults //宣告變數默認值,隨時都可被覆蓋
│ ├── files //檔案放置位置,只要在copy/script module寫對應檔名
即會抓取檔案
│ ├── handlers //宣告handlers,會先讀取main.yml
│ ├── meta //宣告與其他roles的dependencies,會先讀取main.yml
│ ├── tasks //宣告tasks,會先讀取main.yml
│ ├── templates //template放置位置,只要在template module寫對
應檔名即會抓取檔案
│ └── vars //宣告定義變數,會先讀取main.yml