본문 바로가기
IT Knowledge/Ansible

Ansible Semaphore extra CLI Arguments 활용

by Seok. 2022. 6. 21.
반응형

Ansible-Semaphore에서 Task Templates > Advance

Extra CLI Argumens 이용한 활용 방법을 작성합니다. 

 

Extra CLI Arguments, Ansible-playbook 을 실행할 때 추가 arguments를 작성하여 실행하는 것을 말합니다. 

Extra CLI Arguments를 활용하면, Playbook을 실행시마다 내가 원하는 옵션을 추가하여 실행할 수 있습니다. 

예를들면, 특정 Hosts에만 동작한다던지. root 권한으로 실행한다던지 등...

 

[Extra CLI Arguments 사용조건]

Ansible-Semaphore에서 CLI Arguments Override 해서 사용하려면,

아래와 같이 "Allow override CLI args in task" "허용"되어 있어야 합니다.

허용이 되어 있다면, Task RUN 할때 아래와 같이 CLI 추가 입력할 있는 란이 사용됩니다.

예제)

Inventory 포함된 hosts 목록 보기 Inventory 포함된 hosts , haproxy 서버에만 제한적 실행





 

Ansible-playbook Arguments 개요

상세 설명 사용법

공식 ansible Docs : https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html

 

[ -i, --inventory, --inventory-file ]

 : specify inventory host path or comma separated host list. –inventory-file is deprecated

 

[ -l <SUBSET>, --limit <SUBSET>]

 : further limit selected hosts to an additional pattern

 : ex)

$ ansible -m [module]-a "[module options]"--limit "host1"

$ ansible -m [module]-a "[module options]"--limit "host1,host2"

$ ansible -m [module]-a "[module options]"--limit 'all:!host1'

$ ansible -m [module]-a "[module options]"--limit 'group1'

(Note that single quotes MUST be used to prevent bash interpolation.)

 

[--list-hosts]

 : outputs a list of matching hosts; does not execute anything else

 

 

참고 : 

https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html

https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html

반응형

댓글