현재상황
ansible을 설치하고 간단하게 ping을 날렸더니 아래와 같이 warning이 뜬다...
[WARNING]: Platform linux on host ansible-1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change
this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
원인
대부분 linux에서는 python3.x 가 깔려있더라도 /usr/bin/python은 대부분 python2.x으로 잡혀있다.
python3.x를 사용해야하는데 2.x로 잡혀있으니 warning이 발생하는것이다. 해결방법은 다양하다!
해결방법 3가지!
명령어를 사용할때는 아래처럼 -e 옵션으로 환경변수를 지정해주면 된다.
$ ansible localhost -m ping -e 'ansible_python_interpreter=/usr/bin/python3'
$ ansible-playbook sample-playbook.yml -e 'ansible_python_interpreter=/usr/bin/python3'
아니면 영구적으로 지정해주고 싶으면 아래처럼 설정해주면 된다.
# in /etc/ansible/hosts
...
[py3-hosts]
ubuntu16
fedora27
[py3-hosts:vars]
ansible_python_interpreter=/usr/bin/python3
마지막은 playbook에다가 설정해주는법이 있다!
---
- name: ping test
hosts: all
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: ping test
ping:
'Devops > Ansible' 카테고리의 다른 글
to use the 'ssh' connection type with passwords or pkcs11_provider, you must install the sshpass program 에러 해결 (0) | 2022.08.01 |
---|---|
Mac에서 Ansible 설치 및 테스트 하기 (0) | 2022.07.30 |
[Ansible] docker를 이용하여 간단한 ansible 환경 구성하기! (0) | 2021.11.03 |