오픈위키

Ansible 설치하기

2020. 9. 19. 14:57

Ansible 최신 버전 설치 방법 입니다.

id_rsa.pub, authorized_keys 등록없이 사용하는 방법을 공유합니다.

 

설치환경

  • Ubuntu 18.04
  • Ansible 2.9.13

설치하기

$ apt update
$ apt install software-properties-common
$ apt-add-repository --yes --update ppa:ansible/ansible
$ apt install ansible
$ ansible --version
ansible 2.9.13
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Jul 20 2020, 15:37:01) [GCC 7.5.0]

Ansible 설정파일 수정

/etc/ansible/ansible.cfg 와 /etc/ansible/hosts 파일을 수정합니다.

참고링크 : https://github.com/ansible-semaphore/semaphore/issues/309

$ cat /etc/ansible/ansible.cfg
[defaults]
host_key_checking = False
[ssh_connection]
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
control_path = /dev/shm/cp%%h-%%p-%%r
$ cat /etc/ansible/hosts
[child]
182.252.133.71

[child:vars]
ansible_user=root # child 서버 접속 계정
ansible_password=Password1! # child 서버 root 계정 비밀번호

실행하기

ad-hoc 기본 명령어 중 ping으로 동작 확인을 합니다.

$ ansible child -m ping -i /etc/ansible/hosts
182.252.133.71 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

 

이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band