/ ANSIBLE

Ansible 설정하기

[Ansible] 앤서블 설정하기

Ansible

Ansible 공식 문서

ansible.cfg 파일을 수정하여 여러가지 설정을 하려고 할 때, pip 로 설치한 경우 공식 문서에서 example file 을 제공한다길래 들어가봤더니

파일이 삭제되어 있었다…

Starting with Ansible version 2.4, you can use the ansible-config command line utility to list your available options and inspect the current values.

아무래도 ansible 2.4 이후로는 ansible-config 커맨드 라인을 통해 설정을 하는 것 같다.

2023년 7월달 기준으로 ansible 이 8.1 버전인걸 보아하니, 아마도 한참 전에 바뀌었나보다.

Ansible 은 아래와 같은 순서대로 cfg 파일을 찾는다고 하는데, 우선 /etc/ansible 에 간단한 sample cfg 파일을 생성하기로 했다.

  1. ANSIBLE_CONFIG (env 변수가 설정되어 있을 경우)
  2. ansible.cfg (현재 디렉토리에서)
  3. ~/.ansible.cfg (home 디렉토리에서)
  4. /etc/ansible/ansible.cfg (Default 값 인듯)

sample ansible.cfg 파일을 생성

text
$ ansible-config init --disabled > ansible.cfg
$ ansible-config init --disabled -t all > ansible.cfg


명령어 둘 중에 하나를 선택하면 되는데, 둘 다 주석으로 자세히 설명해둔 sample config 파일을 만들어준다고 하고 아래의 명령어가

현재 존재하는 plugin 까지 포함하는 방법이라고 한다.

꽤나 많은 옵션이 존재해서, 필요할 때마다 수정해야겠다.

공식 문서 옵션 설명

ansible.cfg
[ter!
efaults]


# (boolean) By default Ansible will issue a warning when received from a task action (module or action plugin)


# These warnings can be silenced by adjusting this setting to False.


;action_warnings=True


# (list) Accept list of cowsay templates that are 'safe' to use, set to empty list if you want to enable all installed templates.


;cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www


# (string) Specify a custom cowsay path or swap in your cowsay implementation of choice


;cowpath=


# (string) This allows you to chose a specific cowsay stencil for the banners or use 'random' to cycle through them.


;cow_selection=default


# (boolean) This option forces color mode even when running without a TTY or the "nocolor" setting is True.


;force_color=False


# (path) The default root path for Ansible config files on the controller.


;home=~/.ansible


# (boolean) This setting allows suppressing colorizing output, which is used to give a better indication of failure and status information.


;nocolor=False


# (boolean) If you have cowsay installed but want to avoid the 'cows' (why????), use this.


;nocows=False


# (boolean) Sets the default value for the any_errors_fatal keyword, if True, Task failures will be considered fatal errors.


;any_errors_fatal=False


# (path) The password file to use for the become plugin. --become-password-file.


# If executable, it will be run and the resulting stdout will be used as the password.


;become_password_file=


# (pathspec) Colon separated paths in which Ansible will search for Become Plugins.


;become_plugins={ ANSIBLE_HOME ~ "/plugins/become:/usr/share/ansible/plugins/become" } 


# (string) Chooses which cache plugin to use, the default 'memory' is ephemeral.


;fact_caching=memory


# (string) Defines connection or path information for the cache plugin


;fact_caching_connection=


# (string) Prefix to use for cache plugin files/tables


;fact_caching_prefix=ansible_facts


# (integer) Expiration timeout for the cache plugin data


;fact_caching_timeout=86400


# (list) List of enabled callbacks, not all callbacks need enabling, but many of those shipped with Ansible do as we don't want them activated by default.


;callbacks_enabled=


# (string) When a collection is loaded that does not support the running Ansible version (with the collection metadata key `requires_ansible`).


;collections_on_ansible_version_mismatch=warning


# (pathspec) Colon separated paths in which Ansible will search for collections content. Collections must be in nested _subdirectories_, not directly in these directories. For example, if `COLLECTIONS_PATHS` includes `'{ ANSIBLE_HOME ~ "/collections" }'`, and you want to add `my.collection` to that directory, it must be saved as `'{ ANSIBLE_HOME} ~ "/collections/ansible_collections/my/collection" }'`.


;collections_path={ ANSIBLE_HOME ~ "/collections:/usr/share/ansible/collections" }


# (boolean) A boolean to enable or disable scanning the sys.path for installed collections


;collections_scan_sys_path=True


# (path) The password file to use for the connection plugin. --connection-password-file.


;connection_password_file=


# (pathspec) Colon separated paths in which Ansible will search for Action Plugins.


;action_plugins={ ANSIBLE_HOME ~ "/plugins/action:/usr/share/ansible/plugins/action" }