Ansible 시작하기
[Ansible] 앤서블 시작하기
Ansible
Ansible is an IT automation tool.
It can configure systems, deploy software,
and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
Ansible은 공식 홈페이지의 설명대로 CD(continous deployment) 혹은 실시간 롤링 업데이트와 시스템 및 소프트웨어 배포 등을 위한 자동화 도구이다.
클러스터를 구축하는데 Ansible 을 쓰기로 결정한 이유는, 클러스터에 새로운 노드들이 추가될 때마다 매번 셋팅 후 join 시킬 수는 없기 때문이다.
앞으로 무언가를 추가할 때마다 새로운 노드를 셋팅하는 과정이 복잡해지고 시간이 오래 걸리기 때문에 ansible 을 통해 자동화 하는 방법을 택했다.
Ansible은 관리 되는 노드인 Managed node 와, Ansible 을 직접 실행하며 Managed node 를 관리하는 Control Node 로 나뉜다. Control Node 와 Managed Node 는 모두 파이썬을 필요로 하며, Managed Node 는 ssh 가 허용되어 있어야 한다.
Ansible 은 light 버전인 Ansible-core 와, Ansible 로 나뉜다. Kluster 에는 우선 Ansible 을 설치할 것이다. 어느 노드를 Control Node 로 선택할 지 고민을 좀 했는데, 클러스터의 마스터 노드에 직접 Ansible 을 설치하는 것 보다
기존에 Worker Node 중에서 Jenkins 서버를 설치했던 노드에 통합하는 것이 보안 등 여러가지 이유로 좋을 것 같아 Worker Node3(zenkins) 에 설치하기로 했다.
공식 홈페이지에서는 pip 를 이용하여 Ansible 을 설치하는 것을 권장하는 것 같다.
우선 pip 가 설치되어 있는지 확인해보자
text
$ python3 -m pip -V
$ /usr/bin/python3: No module named pip
파이썬 설치가 안되어있으니 빠르게 python 을 설치하자.
text
$ curl <https://bootstrap.pypa.io/get-pip.py> -o get-pip.py
$ python3 get-pip.py --user
pip 23.2 from /home/zenkins/.local/lib/python3.10/site-packages/pip (python 3.10)
다시 한 번 pip 버전을 확인해보니 잘 나오는 모습을 확인할 수 있다.
이제 Ansible 을 설치하자.
text
$ python3 -m pip install --user ansible
$ python3 -m pip install --user ansible-core==2.12.3
ansible 과 ansible-core 중에 선택해서 하나만 설치하면 된다. 위에서 언급했듯이 우리는 ansible 을 먼저 사용해보고 lightweight 버전을 사용할 수 있으면 다운그레이드 하려고 한다.
실행 결과
Collecting ansible
Obtaining dependency information for ansible from [https://files.pythonhosted.org/packages/01/43/b5620e57e14a84d9bf257ba4797c2abfa13f7c3be04bc8cd35f86d2e6a2d/ansible-8.1.0-py3-none-any.whl.metadata](https://files.pythonhosted.org/packages/01/43/b5620e57e14a84d9bf257ba4797c2abfa13f7c3be04bc8cd35f86d2e6a2d/ansible-8.1.0-py3-none-any.whl.metadata)
Downloading ansible-8.1.0-py3-none-any.whl.metadata (7.9 kB)
Collecting ansible-core~=2.15.1 (from ansible)
Obtaining dependency information for ansible-core~=2.15.1 from [https://files.pythonhosted.org/packages/80/71/d2582d918dda323ddf998f8e4bdcc35c5b7fabea27917d480670186d3f39/ansible_core-2.15.1-py3-none-any.whl.metadata](https://files.pythonhosted.org/packages/80/71/d2582d918dda323ddf998f8e4bdcc35c5b7fabea27917d480670186d3f39/ansible_core-2.15.1-py3-none-any.whl.metadata)
Downloading ansible_core-2.15.1-py3-none-any.whl.metadata (7.5 kB)
Requirement already satisfied: jinja2>=3.0.0 in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (3.0.3)
Requirement already satisfied: PyYAML>=5.1 in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (5.4.1)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-core~=2.15.1->ansible) (3.4.8)
Collecting packaging (from ansible-core~=2.15.1->ansible)
Downloading packaging-23.1-py3-none-any.whl (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 579.9 kB/s eta 0:00:00
Collecting resolvelib<1.1.0,>=0.5.3 (from ansible-core~=2.15.1->ansible)
Downloading resolvelib-1.0.1-py2.py3-none-any.whl (17 kB)
Downloading ansible-8.1.0-py3-none-any.whl (44.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.8/44.8 MB 1.1 MB/s eta 0:00:00
Downloading ansible_core-2.15.1-py3-none-any.whl (2.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 1.1 MB/s eta 0:00:00
DEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at [https://github.com/pypa/pip/issues/12063](https://github.com/pypa/pip/issues/12063)
DEPRECATION: python-debian 0.1.43ubuntu1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of python-debian or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at [https://github.com/pypa/pip/issues/12063](https://github.com/pypa/pip/issues/12063)
Installing collected packages: resolvelib, packaging, ansible-core, ansible
WARNING: The scripts ansible, ansible-config, ansible-connection, ansible-console, ansible-doc, ansible-galaxy, ansible-inventory, ansible-playbook, ansible-pull and ansible-vault are installed in '/home/zenkins/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script ansible-community is installed in '/home/zenkins/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed ansible-8.1.0 ansible-core-2.15.1 packaging-23.1 resolvelib-1.0.1
Ansible 을 업그레이드 하기 위해서는 단순히 --upgrade
만 붙이면 된다고 한다
text
$ python3 -m pip install --upgrade --user ansible
ansible-core 버전 확인은
text
$ ansible --version
ansible 버전 확인은
text
python3 -m pip show ansible
을 통해서 하면 된다.
Subscribe to hoeeeeeh
Get the latest posts delivered right to your inbox