반응형
Ansible 인벤토리 설정 및 테스트
1. Ansible Inventory 기본 경로
Ansible은 기본적으로 다음 경로의 인벤토리 파일을 사용한다.
/etc/ansible/hosts
2. 인벤토리 설정
vim /etc/ansible/hosts
[aweb21]
asweb21 ansible_host=10.21.3.54 ansible_connection=ssh ansible_por=22 ansible_user=ec2-user ansible_ssh_private_key_file=~/aws-key/keyfile.pem
asweb22 ansible_host=10.21.4.199 ansible_connection=ssh ansible_por=22 ansible_user=ec2-user ansible_ssh_private_key_file=~/aws-key/keyfile.pem
주요 옵션 설명
- ansible_host: 실제 접속 대상 IP 또는 FQDN
- ansible_connection: 접속 방식 (ssh)
- ansible_port: SSH 포트 (기본 22)
- ansible_user: 접속 사용자
- ansible_ssh_private_key_file: SSH 개인키 경로
3. 인벤토리 확인
전체 호스트 목록 확인
ansible all --list-hosts
hosts (2):
asweb21
asweb22
728x90
4. 연결 테스트 (ping 모듈)
모든 호스트 대상
ansible all -m ping
asweb21 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
asweb22 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
특정 그룹 대상
ansible aweb21 -m ping
asweb21 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
asweb22 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
특정 호스트 대상
ansible asweb21 -m ping
asweb21 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
그룹 변수 설정
[aweb21:vars]
ansible_user=ec2-user
ansible_port=22
접속 디버깅
ansible all -m ping -vvv
728x90
반응형
'퍼블릭 클라우드' 카테고리의 다른 글
| Amazon Linux에 Ansible AWX를 설치하는 방법 (0) | 2021.05.11 |
|---|---|
| Auto Scaling 그룹의 용량을 조정하는 방법 (0) | 2021.05.11 |
| Ansible 인벤토리 설정 (0) | 2021.05.07 |
| [Ansible] MacOS에 Ansible을 설치하기 (0) | 2021.05.07 |
| [Terraform] 테라폼 인스턴스(private) 생성 (0) | 2021.04.30 |