본문 바로가기

퍼블릭 클라우드

[Ansible] MacOS에 Ansible을 설치하기

반응형

MacOS에 Ansible을 설치하기

pip로 Ansible 설치

> pip3 install ansible

> ansible --version
ansible 2.10.9
  config file = None
  configured module search path = ['/Users/sangchul/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.1 (default, Jan  8 2021, 17:17:43) [Clang 12.0.0 (clang-1200.0.32.28)]

로컬호스트에 ansible 테스트

#ping 테스트
> ansible localhost -m ping
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

#명령어(uname -a)  테스트
> ansible localhost -a 'uname -a'

[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | CHANGED | rc=0 >>
Darwin hmac.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64

inventory file(/etc/ansible/hosts) 구성

> sudo mkdir -p /etc/ansible

> sudo touch /etc/ansible/hosts

> sudo chmod 777 /etc/ansible/hosts

> vim /etc/ansible/hosts
[mac]
127.0.0.1

> ansible all --list-hosts
  hosts (1):
    127.0.0.1
    

 

How to build your inventory

 

How to build your inventory — Ansible Documentation

Ansible works against multiple managed nodes or “hosts” in your infrastructure at the same time, using a list or group of lists known as inventory. Once your inventory is defined, you use patterns to select the hosts or groups you want Ansible to run a

docs.ansible.com

 

 

 

728x90
반응형