天天看點

ansible配置檔案管理

文章目錄

    • 4. 管理ansible的配置檔案
      • 4.1 ansible配置檔案的分類
      • 4.2 配置檔案的優先級
    • 5. 如何檢視幫助文檔

4. 管理ansible的配置檔案

4.1 ansible配置檔案的分類

ANSIBLE_CONFIG:首先ansible會檢查目前的環境變量,及這個環境變量指向的配置檔案ANSIBLE_CONFIG。定義了此變量時,Ansible将使用變量所指定的配置檔案,而不用其他任何配置檔案。

./ansible.cfg:如果沒有設定該變量的情況下則會去查找目前運作ansible的目錄中是否有ansible.cfg檔案。

~/ansible.cfg:如果在目前運作ansible的目錄中沒有找到ansible檔案的話則會去查找家目錄中是否有ansible.cfg檔案

/etc/ansible/ansible.cfg:最後如果家目錄下沒有此檔案的話将會檢查在安裝Ansible時自動生産的配置檔案。

4.2 配置檔案的優先級

ANSIBLE_CONFIG > 目前目錄下的ansible.cfg > ~/.ansible.cfg > /etc/ansible/ansible.cfg

5. 如何檢視幫助文檔

ansible擁有上千個插件和子產品,可以實作各種軟體、平台 、版本的管理,并且支援虛拟容器的多層級的部署

可以通過以下指令檢視ansible子產品和插件的幫助文檔

[[email protected] ansible]# ansible-doc
usage: ansible-doc [-h] [--version] [-v] [-M MODULE_PATH]
                   [--playbook-dir BASEDIR]
                   [-t {become,cache,callback,cliconf,connection,httpapi,inventory,lookup,netconf,shell,module,strategy,vars}]
                   [-j] [-F | -l | -s | --metadata-dump]
                   [plugin [plugin ...]]

plugin documentation tool

positional arguments:
  plugin                Plugin

optional arguments:
  --metadata-dump       **For internal testing only** Dump json metadata for
                        all plugins.
  --playbook-dir BASEDIR
                        Since this tool does not use playbooks, use this as a
                        substitute playbook directory.This sets the relative
                        path for many features including roles/ group_vars/
                        etc.
  --version             show program's version number, config file location,
                        configured module search path, module location,
                        executable location and exit
  -F, --list_files      Show plugin names and their source files without
                        summaries (implies --list)
  -M MODULE_PATH, --module-path MODULE_PATH
                        prepend colon-separated path(s) to module library (def
                        ault=~/.ansible/plugins/modules:/usr/share/ansible/plu
                        gins/modules)
  -h, --help            show this help message and exit
  -j, --json            Change output into json format.
  -l, --list            List available plugins
  -s, --snippet         Show playbook snippet for specified plugin(s)
  -t {become,cache,callback,cliconf,connection,httpapi,inventory,lookup,netconf,shell,module,strategy,vars}, --type {become,cache,callback,cliconf,connection,httpapi,inventory,lookup,netconf,shell,module,strategy,vars}
                        Choose which plugin type (defaults to "module").
                        Available plugin types are : ('become', 'cache',
                        'callback', 'cliconf', 'connection', 'httpapi',
                        'inventory', 'lookup', 'netconf', 'shell', 'module',
                        'strategy', 'vars')
  -v, --verbose         verbose mode (-vvv for more, -vvvv to enable
                        connection debugging)

See man pages for Ansible CLI options or website for tutorials
https://docs.ansible.com

           

也可以直接官網進行檢視幫助文檔