Kylin Linux V10 SP1 上での Ansible インストールと展開

1. YUM を使ってオンラインでインストール

1.1 システムバージョンを確認


    [root@kylin-server1 ~]# nkvers
    ############## Kylin Linux Version
    #################
    Release:
    Kylin Linux Advanced Server release V10
    (Tercel)
     
    Kernel:
    4.19.90-23.8.v2101.ky10.x86_64
     
    Build:
    Kylin Linux Advanced Server
    release V10 (SP1) /(Tercel)-x86_64-Build20/20210518
    #################################################
    

1.2 YUM ソースの設定を確認


    [root@kylin-server1 ~]# cd /etc/yum.repos.d/
    [root@kylin-server1 yum.repos.d]# ls
    kylin_x86_64.repo
    [root@kylin-server1 yum.repos.d]# cat kylin_x86_64.repo
    ###Kylin Linux Advanced Server 10 - os repo###
    
    [ks10-adv-os]
    name = Kylin Linux Advanced Server 10 - Os
    baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/base/$basearch/
    gpgcheck = 1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
    enabled = 1
    
    [ks10-adv-updates]
    name = Kylin Linux Advanced Server 10 - Updates
    baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/updates/$basearch/
    gpgcheck = 1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
    enabled = 1
    
    [ks10-adv-addons]
    name = Kylin Linux Advanced Server 10 - Addons
    baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/addons/$basearch/
    gpgcheck = 1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
    enabled = 0
    [root@kylin-server1 yum.repos.d]#
    

1.3 YUM を使って Ansible 2.8.8 をインストール


    [root@kylin-server1 ~]# yum install ansible
    Last metadata expiration check: 0:23:38 ago on 2024年07月11日 星期四 14時03分05秒.
    Dependencies resolved.
    ==============================================================================================================================
    Package                             Architecture            Version                            Repository                         Size
    ==============================================================================================================================
    Installing:
    ansible                             noarch                  2.8.8-1.p01.ky10                   ks10-adv-updates                   15 M
    Installing dependencies:
    libsodium                           x86_64                  1.0.16-7.ky10                      ks10-adv-os                       146 k
    python3-babel                       noarch                  2.7.0-1.ky10                       ks10-adv-os                       5.9 M
    python3-bcrypt                      x86_64                  3.1.4-7.ky10                       ks10-adv-os                        39 k
    python3-markupsafe                  x86_64                  1.0-3.ky10                         ks10-adv-os                        28 k
    python3-paramiko                    noarch                  2.4.3-1.ky10.ky10                  ks10-adv-os                       281 k
    python3-pyasn1                      noarch                  0.3.7-8.ky10                       ks10-adv-os                       215 k
    python3-pynacl                      x86_64                  1.2.1-4.ky10                       ks10-adv-os                        77 k
    python3-pyyaml                      x86_64                  5.1.2-1.ky10                       ks10-adv-os                       187 k
    sshpass                             x86_64                  1.06-8.ky10                        ks10-adv-os                        24 k
    python3-jinja2                      noarch                  2.11.2-2.p01.ky10                  ks10-adv-updates                  223 k

    Transaction Summary
    ==============================================================================================================================
    Install  11 Packages

    Total download size: 22 M
    Installed size: 109 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/11): python3-bcrypt-3.1.4-7.ky10.x86_64.rpm                                                          369 kB/s |  39 kB     00:00
    (2/11): libsodium-1.0.16-7.ky10.x86_64.rpm                                                              1.0 MB/s | 146 kB     00:00
    (3/11): python3-markupsafe-1.0-3.ky10.x86_64.rpm                                                        587 kB/s |  28 kB     00:00
    (4/11): python3-pyasn1-0.3.7-8.ky10.noarch.rpm                                                          1.0 MB/s | 215 kB     00:00
    (5/11): python3-paramiko-2.4.3-1.ky10.ky10.noarch.rpm                                                   1.1 MB/s | 281 kB     00:00
    (6/11): python3-pynacl-1.2.1-4.ky10.x86_64.rpm                                                          960 kB/s |  77 kB     00:00
    (7/11): python3-pyyaml-5.1.2-1.ky10.x86_64.rpm                                                          2.1 MB/s | 187 kB     00:00
    (8/11): sshpass-1.06-8.ky10.x86_64.rpm                                                                  311 kB/s |  24 kB     00:00
    (9/11): python3-babel-2.7.0-1.ky10.noarch.rpm                                                           5.5 MB/s | 5.9 MB     00:01
    (10/11): python3-jinja2-2.11.2-2.p01.ky10.noarch.rpm                                                    211 kB/s | 223 kB     00:01
    (11/11): ansible-2.8.8-1.p01.ky10.noarch.rpm                                                            8.7 MB/s |  15 MB     00:01
    ----------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                    10 MB/s |  22 MB     00:02
    

1.4 使用をテスト


    [root@kylin-server1 ~]# ansible localhost -m ping
    localhost | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    

2. PIP を使ってオンラインでインストール

2.1 PIP をインストール


    [root@kylin-server1 ~]# yum install python3-pip
    Last metadata expiration check: 0:00:30 ago on 2024年07月11日 星期四 15時30分07秒.
    Dependencies resolved.
    ==============================================================================================================================
    Package                        Architecture              Version                             Repository                           Size
    ==============================================================================================================================
    Installing:
    python3-pip                    noarch                    20.2.2-6.ky10                       ks10-adv-updates                    2.2 M

    Transaction Summary
    ==============================================================================================================================
    Install  1 Package

    Total download size: 2.2 M
    Installed size: 9.4 M
    Is this ok [y/N]: y
    Downloading Packages:
    python3-pip-20.2.2-6.ky10.noarch.rpm                                                                    6.1 MB/s | 2.2 MB     00:00
    

2.2 PIP を使って Ansible 2.8.8 をインストール


    [root@kylin-server1 ~]# pip3 install ansible==2.8.8
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting ansible==2.8.8
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/68/43/92d5b1921f38b01a7af4e4b39233f25a4512b62fa69a8c757e76a4601596/ansible-2.8.8.tar.gz (12.7 MB)
         |████████████████████████████████| 12.7 MB 1.3 MB/s
    Collecting jinja2
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/31/80/3a54838c3fb461f6fec263ebf3a3a41771bd05190238de3486aae8540c36/jinja2-3.1.4-py3-none-any.whl (133 kB)
         |████████████████████████████████| 133 kB 1.1 MB/s
    Collecting PyYAML
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d7/8f/db62b0df635b9008fe90aa68424e99cee05e68b398740c8a666a98455589/PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (670 kB)
         |████████████████████████████████| 670 kB 1.8 MB/s
    Requirement already satisfied: cryptography in /usr/lib64/python3.7/site-packages (from ansible==2.8.8) (2.6.1)
    Collecting MarkupSafe>=2.0
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4a/1d/c4f5016f87ced614eacc7d5fb85b25bcc0ff53e8f058d069fc8cbfdc3c7a/MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
    Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python3.7/site-packages (from cryptography->ansible==2.8.8) (0.24.0)
    Requirement already satisfied: six>=1.4.1 in /usr/lib/python3.7/site-packages (from cryptography->ansible==2.8.8) (1.12.0)
    Requirement already satisfied: cffi!=1.11.3,>=1.8 in /usr/lib64/python3.7/site-packages (from cryptography->ansible==2.8.8) (1.11.5)
    Requirement already satisfied: pycparser in /usr/lib/python3.7/site-packages (from cffi!=1.11.3,>=1.8->cryptography->ansible==2.8.8) (2.19)
    Using legacy 'setup.py install' for ansible, since package 'wheel' is not installed.
    Installing collected packages: MarkupSafe, jinja2, PyYAML, ansible
        Running setup.py install for ansible ... done
    Successfully installed MarkupSafe-2.1.5 PyYAML-6.0.1 ansible-2.8.8 jinja2-3.1.4
    

3. オフラインインストール

3.1 Ansible に必要な依存パッケージをダウンロード


    [root@kylin-server2 ~]# ll ansible-pkgs/
    総用量 22252
    -rw-r--r-- 1 root root 15321140  7月 11 14:39 ansible-2.8.8-1.p01.ky10.noarch.rpm
    -rw-r--r-- 1 root root   149100  7月 11 14:39 libsodium-1.0.16-7.ky10.x86_64.rpm
    -rw-r--r-- 1 root root  6189420  7月 11 14:39 python3-babel-2.7.0-1.ky10.noarch.rpm
    -rw-r--r-- 1 root root    40260  7月 11 14:39 python3-bcrypt-3.1.4-7.ky10.x86_64.rpm
    -rw-r--r-- 1 root root   228612  7月 11 14:39 python3-jinja2-2.11.2-2.p01.ky10.noarch.rpm
    -rw-r--r-- 1 root root    29108  7月 11 14:39 python3-markupsafe-1.0-3.ky10.x86_64.rpm
    -rw-r--r-- 1 root root   287484  7月 11 14:39 python3-paramiko-2.4.3-1.ky10.ky10.noarch.rpm
    -rw-r--r-- 1 root root   220644  7月 11 14:39 python3-pyasn1-0.3.7-8.ky10.noarch.rpm
    -rw-r--r-- 1 root root    78680  7月 11 14:39 python3-pynacl-1.2.1-4.ky10.x86_64.rpm
    -rw-r--r-- 1 root root   191612  7月 11 14:39 python3-pyyaml-5.1.2-1.ky10.x86_64.rpm
    -rw-r--r-- 1 root root    25088  7月 11 14:39 sshpass-1.06-8.ky10.x86_64.rpm
    

3.2 RPM を使って Ansible 2.8.8 をインストール


    [root@kylin-server2 ansible-pkgs]# rpm -ivh *.rpm
    警告:ansible-2.8.8-1.p01.ky10.noarch.rpm: 头V4 RSA/SHA1 Signature, 密鑰 ID 7a486d9f: NOKEY
    Verifying...                          ################################# [100%]
    准備中...                          ################################# [100%]
    升级/インストール中...
       1:sshpass-1.06-8.ky10              ################################# [  9%]
       2:python3-pyyaml-5.1.2-1.ky10      ################################# [ 18%]
       3:python3-pyasn1-0.3.7-8.ky10      ################################# [ 27%]
       4:python3-markupsafe-1.0-3.ky10    ################################# [ 36%]
       5:python3-bcrypt-3.1.4-7.ky10      ################################# [ 45%]
       6:python3-babel-2.7.0-1.ky10       ################################# [ 55%]
       7:python3-jinja2-2.11.2-2.p01.ky10 ################################# [ 64%]
       8:libsodium-1.0.16-7.ky10          ################################# [ 73%]
       9:python3-pynacl-1.2.1-4.ky10      ################################# [ 82%]
      10:python3-paramiko-2.4.3-1.ky10.ky1################################# [ 91%]
      11:ansible-2.8.8-1.p01.ky10         ################################# [100%]
    

3.3 使用をテスト


    [root@kylin-server2 ansible-pkgs]# ansible localhost -m ping
    localhost | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    

3.3.1 常見の問題

問題1:

        [root@kylin-server2 ansible-pkgs]# ansible server -m ping
        [WARNING]: Platform linux on host 192.168.111.112 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.8/reference_appendices/interpreter_discovery.html for more information.

        192.168.111.112 | SUCCESS => {
            "ansible_facts": {
                "discovered_interpreter_python": "/usr/bin/python"
            },
            "changed": false,
            "ping": "pong"
        }
        [root@kylin-server2 ansible-pkgs]# ansible server -m ping
        192.168.111.113 | SUCCESS => {
            "ansible_facts": {
                "discovered_interpreter_python": "/usr/bin/python"
            },
            "changed": false,
            "ping": "pong"
        }
        
問題2:

        [root@kylin-server2 ~]# ansible server -m ping
        192.168.111.112 | FAILED! => {
            "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."
        }
        192.168.111.113 | SUCCESS => {
            "ansible_facts": {
                "discovered_interpreter_python": "/usr/bin/python"
            },
            "changed": false,
            "ping": "pong"
        }
        
問題3:

        [root@kylin-server1 ~]# ansible localhost -m shell -a "uname -a"

        [WARNING]: No inventory was parsed, only implicit localhost is available

        [WARNING]: Skipping plugin (/usr/local/lib/python3.7/site-packages/ansible/plugins/filter/core.py) as it seems to be invalid: cannot
        import name 'environmentfilter' from 'jinja2.filters' (/usr/local/lib/python3.7/site-packages/jinja2/filters.py)

        [WARNING]: Skipping plugin (/usr/local/lib/python3.7/site-packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid:
        cannot import name 'environmentfilter' from 'jinja2.filters' (/usr/local/lib/python3.7/site-packages/jinja2/filters.py)

        localhost | CHANGED | rc=0 >>
        Linux kylin-server1 4.19.90-23.8.v2101.ky10.x86_64 #1 SMP Mon May 17 17:08:34 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
        

タグ: linux ansible Yum PIP RPM

5月23日 12:53 投稿