ansible.cfg 範例

  1. Ansible 在 /etc/ansible 目錄下有組態設定範例檔 ansible.cfg,包含以下章節:
    [root@kvm19 ansible]# egrep -v '^(#|$)' /etc/ansible/ansible.cfg 
    [defaults]
    [inventory]
    [privilege_escalation]
    [paramiko_connection]
    [ssh_connection]
    [persistent_connection]
    [accelerate]
    [selinux]
    [colors]
    [diff]
    
  2. 查看 [defaults] 章節的部分設定範例如下,例如:inventory 設定 inventory 檔的位置,role_path 設定使用於 playbooks 的角色的位置。
    [root@kvm19 ansible]# cat /etc/ansible/ansible.cfg | \
    grep '^\[defaults' -A60 | egrep '^(\[|#[a-z])'
    [defaults]
    #inventory      = /etc/ansible/hosts
    #library        = /usr/share/my_modules/
    #module_utils   = /usr/share/my_module_utils/
    #remote_tmp     = ~/.ansible/tmp
    #local_tmp      = ~/.ansible/tmp
    #plugin_filters_cfg = /etc/ansible/plugin_filters.yml
    #forks          = 5
    #poll_interval  = 15
    #sudo_user      = root
    #ask_sudo_pass = True
    #ask_pass      = True
    #transport      = smart
    #remote_port    = 22
    #module_lang    = C
    #module_set_locale = False
    #gathering = implicit
    #gather_subset = all
    #roles_path    = /etc/ansible/roles