Ansible2.10(离线安装)

首先

Ansible 2.10开始,与传统的Ansible 2.9不同的是,大部分模块都被集中到了ansible-galaxy中,并开始提供最基本的ansible-base模块。然而,Ansible 2.10有两种安装方式:
1. Ansible-base:只提供ansible-base,仅包含最基本的模块和插件,需要的模块可以从ansible-galaxy获取。
2. Ansible:与传统的分发方式相同,是将模块和插件绑定到ansible-base形式。

本文中介绍了进行②Ansible的离线安装。
※ 关于①Ansible-base的内容,请参阅另一篇文章。

0. 前提

将以下资源带到离线环境并安装。
通过pip安装的资源(使用pip list确认)。

pip-21.0.1.tar.gz 
wheel-0.36.2.tar.gz
setuptools-54.2.0.tar.gz 

※pip的离线升级

# pip3 install --upgrade /tmp/pip/pip-20.3.3.tar.gz

用rpm安装的东西。

sshpass-1.06-9.el8.x86_64.rpm

1. 下载ansible2.10安装文件。

使用pip命令下载ansible2.10安装文件。
执行结果如下:

# pip3 download -d ansible ansible
# ls -ltr
合計 37164
-rw-r--r--. 1 root root 28622006 12月 19 19:28 ansible-2.10.4.tar.gz
-rw-r--r--. 1 root root  5708083 12月 19 19:28 ansible-base-2.10.4.tar.gz
-rw-r--r--. 1 root root   125774 12月 19 19:28 Jinja2-2.11.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root   269377 12月 19 19:28 PyYAML-5.3.1.tar.gz
-rw-r--r--. 1 root root  2655338 12月 19 19:28 cryptography-3.3.1-cp36-abi3-manylinux1_x86_64.whl
-rw-r--r--. 1 root root    39857 12月 19 19:28 packaging-20.8-py2.py3-none-any.whl
-rw-r--r--. 1 root root    27520 12月 19 19:28 MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r--. 1 root root    10963 12月 19 19:28 six-1.15.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root   401227 12月 19 19:28 cffi-1.14.4-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r--. 1 root root    67842 12月 19 19:28 pyparsing-2.4.7-py2.py3-none-any.whl
-rw-r--r--. 1 root root   112041 12月 19 19:28 pycparser-2.20-py2.py3-none-any.whl

2. 安装

用以下的步骤将下载的资源配置到离线环境中。
运行以下命令来安装ansible。

# pip3 install <パッケージ名>

检查是否已安装。

# ansible --version
ansible 2.10.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

执行用于测试的playbook。

我制作了以下的测试用playbook,并进行了运行确认。

---
  - hosts: localhost

    tasks:
      - file:
          path: /tmp
          state: directory

下面是执行结果。可以确认Ansible正常运行。

# # ansible-playbook test.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [file] ********************************************************************
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

4. 互相依賴關係

以下是依存关系

$ pipdeptree
ansible==2.10.7
  - ansible-base [required: >=2.10.5,<2.11, installed: 2.10.6]
    - cryptography [required: Any, installed: 2.3]
      - asn1crypto [required: >=0.21.0, installed: 0.24.0]
      - cffi [required: >=1.7,!=1.11.3, installed: 1.11.5]
        - pycparser [required: Any, installed: 2.14]
      - idna [required: >=2.1, installed: 2.5]
      - six [required: >=1.4.1, installed: 1.11.0]
    - jinja2 [required: Any, installed: 2.10.1]
      - MarkupSafe [required: >=0.23, installed: 0.23]
    - packaging [required: Any, installed: 20.9]
      - pyparsing [required: >=2.0.2, installed: 2.4.7]
    - PyYAML [required: Any, installed: 3.12]
    - $ pipdeptree
ansible==2.10.7
  - ansible-base [required: >=2.10.5,<2.11, installed: 2.10.6]
    - cryptography [required: Any, installed: 2.3]
      - asn1crypto [required: >=0.21.0, installed: 0.24.0]
      - cffi [required: >=1.7,!=1.11.3, installed: 1.11.5]
        - pycparser [required: Any, installed: 2.14]
      - idna [required: >=2.1, installed: 2.5]
      - six [required: >=1.4.1, installed: 1.11.0]
    - jinja2 [required: Any, installed: 2.10.1]
      - MarkupSafe [required: >=0.23, installed: 0.23]
    - packaging [required: Any, installed: 20.9]
      - pyparsing [required: >=2.0.2, installed: 2.4.7]
    - PyYAML [required: Any, installed: 3.12]
广告
将在 10 秒后关闭
bannerAds