보조기억장치

ansible 테스트 본문

Linux

ansible 테스트

캐세이 2023. 5. 8. 09:15

ping 테스트

# ansible all --key-file ~/.ssh/ansible -i inventory -m ping
192.168.0.112 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.0.113 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}

 

ansible 환경설정 파일 만들기

# nano ansible.cfg 
[defaults]
inventory = inventory
private_key_file = ~/.ssh/ansible

 

호스트 조회

# ansible all --list-hosts
  hosts (2):
    192.168.0.112
    192.168.0.113

 

호스트정보 가져오기

# ansible all -m gather_facts

# ansible all -m gather_facts --limit 192.168.0.112 (특정 호스트만)

 

sudo  권한 가져오기

# ansible all -m dnf -a update_cache=true --become --ask-become-pass

 

패키지 설치/업데이트/삭제

$ ansible all -m yum -a name=nginx --become --ask-become-pass
$ ansible all -m yum -a "name=nginx state=latest" --become --ask-become-pass

'Linux' 카테고리의 다른 글

ansible yaml example  (0) 2023.05.09
ubuntu apt update 에러  (0) 2023.05.09
ansible 설정  (0) 2023.05.08
Module yaml error: Unexpected key in data: static_context [line 9 col 3] 에러  (0) 2023.04.20
Bash 예제  (0) 2023.04.18