퍼블릭 클라우드
[Ansible] ansible 인벤토리 설정 파일
변군이글루
2021. 5. 7. 16:39
반응형
ansible 인벤토리 설정 파일
인벤토리 설정
기본적으로 /etc/ansible/hosts 파일 사용한다
> 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 all --list-hosts
hosts (2):
asweb21
asweb22
# 인벤토리(hosts)에 있는 모든 호스트
> 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"
}
명령어 테스트(uptime 명령어)
> ansible agweb21 -a uptime
asweb22 | CHANGED | rc=0 >>
07:42:18 up 42 min, 1 user, load average: 0.00, 0.00, 0.00
asweb21 | CHANGED | rc=0 >>
07:42:18 up 42 min, 1 user, load average: 0.00, 0.00, 0.00
728x90
반응형