목차
Installing Ansible — Ansible Documentation
If you are testing new features, fixing bugs, or otherwise working with the development team on changes to the core code, you can install and run the source from GitHub. Note You should only install and run the devel branch if you are modifying ansible-cor
docs.ansible.com
위 가이드 문서를 보고 진행한 내용. 기본적으로 Python 설치도 되어 있어야 한다.
apt로 설치하면 2.9 이하로 설치되니 그 방식으로는 하면 안된다.
본 문서는 ansible 2.13 버전을 설치해보는 예제. Ubuntu 18.04에서 테스트해보았다.
[노드 요구사항 요약]
ansible-core version | Control node Python | Managed node Python |
2.11 | Python 2.7, Python 3.5 - 3.9 | Python 2.6 - 2.7, Python 3.5 - 3.9 |
2.12 | Python 3.8 - 3.10 | Python 2.6 - 2.7, Python 3.5 - 3.10 |
2.13 | Python 3.8 - 3.10 | Python 2.7, Python 3.5 - 3.10 |
2.14 | Python 3.9 - 3.11 | Python 2.7, Python 3.5 - 3.10 |
ansible 2.12 버전을 설치하려면 Python 3.8 - 3.10 버전 사이가 필요하다.
[Python 찾기]
ansible 설치 전에 Python 버전 확인을 진행한다.
python이 설치되지 않은 경우 설치를 진행한다.
### python 버전 체크
$ python3 --version
### python3.8 버전 이하라면 설치 진행. 기존에 3.6 버전이 깔려있었다면 변경이 필요하다.
$ sudo apt update -y
$ sudo apt install python3.8
$ sudo apt-get install python3-distutils
$ sudo apt-get install python3-apt
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
### python 3.8을 바라보도록 해주어야 한다.
$ sudo update-alternatives --config python3
#$ sudo rm /usr/bin/python3
#$ sudo ln -s python3.8 /usr/bin/python3
### 버전 확인 (3.8로 표기되면 됨)
$ python3 -V
$ python3 -m pip -V
# 정상일 경우 아래와 같이 표시
pip 23.0.1 from /usr/lib/python3.8/site-packages/pip (python 3.8)
위와 같이 표시되지 않는다면 pip를 설치한다.
### pip 설치 (경로 확인)
#pip는 파이썬 패키지 라이브러리 관리 시스템을 말한다.
### pip 다운로드
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
### pip 설치 (해당 user only)
$ python3 get-pip.py --user
Successfully installed pip-21.3.1 wheel-0.37.1
[Ansible 설치]
Ansible 2.9 이하 버전이 apt로 설치되어 있었다면 우선 삭제한다. (삭제하지 않으니 꼬일때가 있다)
### ansible 2.9이하 버전이 설치된 경우 삭제
$ ansible --version
$ sudo apt remove ansible
Ansible 설치 진행
### 설치가능한 버전 자동 선정
$ python3 -m pip install --user ansible
### 특정 버전으로 설치 (Optional)
# $python3 -m pip install --user ansible-core==2.12.3
### 업그레이드 할 경우 (Optional)
# $python3 -m pip install --upgrade --user ansible
Ansible 버전 확인. 재접속 후 확인한다.
### 확인
$ ansible-galaxy collection list
$ ansible --version
[Trouble Shooting]
python3-apt 관련 오류
python3-apt 삭제 후 재설치. 주로 기존에 깔려있던 python을 사용하지 않고 새로운 버전을 설치했을 때 발생한다고 한다.
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
$ apt-get remove python3-apt
$ apt-get install python3-apt
https://peanut159357.tistory.com/m/182
apt install pip 과정에서 실패할 경우
대상 서버에서 아래 커맨드 수행
$ apt-get update --fix-missing
'이것저것' 카테고리의 다른 글
Intellij에서 google-java-style 적용하기 (0) | 2024.05.31 |
---|---|
nGrinder (0) | 2023.04.08 |
JMeter (0) | 2023.04.01 |
Intellij 단축키 모음 (0) | 2023.03.09 |
MSA에서 Outbox Pattern에 대해 (0) | 2022.11.20 |