Ansible 小手冊系列 十九(常見指令表)

Play


指令 說明
accelerate 開啓加速模式
accelerate_ipv6 是否開啓ipv6
accelerate_port 加速模式的端口
always_run  
any_errors_fatal 有任務錯誤時,當即中止
become 是否提權
become_flags 提權命令的參數
become_method 提權得方式
become_user 提權的用戶
check_mode 當爲True時,只檢查,不作修改
connection 鏈接方式
environment 定義遠端系統的環境變量
force_handlers 任務失敗後,是否依然執行handlers中的任務
gather_facts 是否獲取遠端系統得facts
gather_subset 獲取facts得哪些鍵值
gather_timeout 獲取facts的超時時間
handlers 定義task執行完成之後須要調用的任務
hosts 指定運行得主機
ignore_errors 是否忽略錯誤
max_fail_percentage 最大的錯誤主機數,超過則當即中止ansbile
name 定義任務得名稱
no_log 不記錄日誌
port 定義ssh的鏈接端口
post_tasks 執行任務後要執行的任務
pre_tasks 執行任務前要執行的任務
remote_user 遠程登錄的用戶
roles 定義角色
run_once 任務只運行一次
serial 任務每次執行的主機數
strategy play運行的模式
tags 標記標籤
tasks 定義任務
vars 定義變量
vars_files 包含變量文件
vars_prompt 要求用戶輸入內容
vault_password 加密密碼

Role


指令 說明
always_run  
become 是否提權
become_flags 提權命令的參數
become_method 提權的方式
become_user 提權的用戶
check_mode 當爲True時,只檢查,不作修改
connection 鏈接方式
delegate_facts 委託facts
delegate_to 任務委派
environment 定義遠端系統的環境變量
ignore_errors 是否忽略錯誤
no_log 不記錄日誌
port 定義ssh的鏈接端口
remote_user 遠端系統的執行用戶
run_once 只運行一次
tags 標記標籤
vars 定義變量
when 條件表達式結果爲True則執行block

Block


指令 說明
always always裏的任務老是執行
always_run  
any_errors_fatal 有錯誤時當即中斷ansbile
become 是否提權
become_flags 提權命令的參數
become_method 提權的方式
become_user 提權的用戶
block 分組執行
check_mode 當爲True時,只檢查,不作修改
connection 鏈接方式
delegate_facts 委託facts
delegate_to 任務委派
environment 定義遠端系統的環境變量
ignore_errors 是否忽略錯誤
no_log 不記錄日誌
port 定義ssh的鏈接端口
remote_user 遠端系統的執行用戶
rescue block中的任務在執行中,若是有任何錯誤,將執行rescue中的任務。
run_once 只運行一次
tags 標記標籤
vars 定義變量
when 條件表達式結果爲True則執行block

Task


  說明
action 執行動做
always_run  
any_errors_fatal 爲True時,只要任務有錯誤,就當即中止ansible
args 定義任務得參數
async 是否異步執行任務
become 是否提權
become_flags 提權命令的參數
become_method 提權的方式
become_user 提權的用戶
changed_when 條件表達式爲True時,使任務狀態爲changed
check_mode 爲True時,只檢查運行狀態,在遠端不作任何修改
connection 鏈接方式
delay 等待多少秒,才執行任務
delegate_facts 委託facts
delegate_to 任務委派
environment 定義遠端的環境變量
failed_when 條件表達式爲True時,使任務爲失敗狀態
ignore_errors 是否忽略錯誤
local_action 本地執行
loop  
loop_args  
loop_control 改變循環的變量項
name 定義人物的名稱
no_log 不記錄日誌
notify 用於任務執行完,執行handlers裏的任務
poll 輪詢時間
port 定義ssh的鏈接端口
register 註冊變量
remote_user 遠端系統的執行用戶
retries 重試次數
run_once 只運行一次
tags 標記爲標籤
until 直到爲真時,才繼續執行任務
vars 定義變量
when 條件表達式,結果爲True則執行task
with_<lookup_plugin> 循環
相關文章
相關標籤/搜索