변군이글루 블로그(Development)
Ansible 구성 설정(Configuration Settings) 파일의 우선 순위에 대한 설명 본문
728x90
Ansible 구성 설정(Configuration Settings) 파일의 우선 순위에 대한 설명
구성 설정 파일(ansible.cfg)의 우선 순위
1. 환경 변수 (Environment Variables)
- Ansible은 ANSIBLE_CONFIG 환경 변수를 통해 구성 파일의 경로를 지정할 수 있습니다. 이 환경 변수가 설정되어 있으면 해당 경로의 구성 파일이 사용됩니다.
export ANSIBLE_CONFIG=/path/to/your/ansible.cfg
2. 커맨드 라인 인수 (Command Line Arguments)
- ansible-playbook이나 ansible 명령을 실행할 때 -i나 -e와 같은 인수를 사용하여 구성을 지정할 수 있습니다. 이는 명령이 실행되는 동안 구성을 임시로 설정하는 데 사용됩니다.
ansible-playbook -i inventory.ini -e "ansible_user=myuser" myplaybook.yml
3. 현재 디렉토리에 있는 ansible.cfg 파일
- Ansible은 실행 중인 디렉토리에서 ansible.cfg 파일을 검색합니다. 현재 디렉토리에 구성 파일이 있으면 해당 파일이 사용됩니다.
ls -l ansible.cfg
4. 홈 디렉토리에 있는 .ansible.cfg 파일
- 사용자의 홈 디렉토리에 .ansible.cfg 파일이 있으면 해당 파일이 사용됩니다. 이 파일은 사용자의 홈 디렉토리에 위치하며 전역 설정으로 사용됩니다.
ls -l ~/.ansible.cfg
5. 시스템 전역 설정 파일(/etc/ansible/ansible.cfg)
- Ansible은 /etc/ansible/ansible.cfg 경로에 위치한 시스템 전역 설정 파일도 읽습니다. 이 파일은 시스템 전체에 적용되는 전역 구성을 설정하는 데 사용됩니다.
ls -l /etc/ansible/ansible.cfg
728x90
- ansible version 명령으로 현재 적용되고 있는 구성 파일(ansible.cfg)을 확인할 수 있음.
ansible --version
$ ansible --version
ansible 2.9.27
config file = /home/tuser/ansible-spec/ansible.cfg
configured module search path = [u'/home/tuser/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Jun 28 2022, 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
- 인벤토리(inventory) 파일 확인
cat ~/ansible-spec/ansible.cfg | egrep '^inventory'
$ cat ~/ansible-spec/ansible.cfg | egrep '^inventory'
inventory = ~/ansible-spec/inventory
참고URL
- Ansible DOCS(docs.ansible.com) : https://docs.ansible.com/ansible/latest/reference_appendices/config.html
- [Ansible] inventory(인벤토리) 설정 : https://scbyun.com/998
728x90
'리눅스' 카테고리의 다른 글
파이썬 가상 환경을 구성하고 설정하는 방법(python virtual environment) (0) | 2022.11.07 |
---|---|
Ansible 인벤토리를 YAML 파일로 설정하는 방법 (0) | 2022.10.31 |
레디스 클러스터를 설정하는 방법(redis cluster setup) (0) | 2022.10.27 |
우분투에서 Redis 서버를 소스 코드로 컴파일하여 설치하는 방법(소스 컴파일) (0) | 2022.10.27 |
[draft] 우분투에서 SquashFS를 사용하는 방법 (0) | 2022.10.24 |