【Kylin环境离线安装ansible 】

Kylin环境离线安装ansible

1.登录一个可以联网的机器,下载ansible并制作离线包

1.1 查看依赖包 yum deplist ansible

[root@tpcc-armA ~]# yum deplist ansible
Last metadata expiration check: 2:13:07 ago on 2023年11月12日 星期日 08时27分52秒.
package: ansible-2.8.8-1.ky10.noarch
  dependency: /usr/bin/python3
   provider: python3-3.7.9-20.p07.se.ky10.aarch64
  dependency: python(abi) = 3.7
   provider: python3-3.7.9-20.p07.se.ky10.aarch64
  dependency: python3-cryptography
   provider: python3-cryptography-2.9.2-2.ky10.aarch64
  dependency: python3-jinja2
   provider: python3-jinja2-2.11.2-2.p01.ky10.noarch
  dependency: python3-paramiko
   provider: python3-paramiko-2.4.3-1.ky10.ky10.noarch
  dependency: python3-pyyaml
   provider: python3-pyyaml-5.1.2-1.ky10.aarch64
  dependency: python3-setuptools
   provider: python3-setuptools-44.1.1-2.ky10.noarch
  dependency: python3-six
   provider: python3-six-1.12.0-1.ky10.noarch
  dependency: python3.7dist(cryptography)
   provider: python3-cryptography-2.9.2-2.ky10.aarch64
  dependency: python3.7dist(jinja2)
   provider: python3-jinja2-2.11.2-2.p01.ky10.noarch
  dependency: python3.7dist(pyyaml)
   provider: python3-pyyaml-5.1.2-1.ky10.aarch64
  dependency: sshpass
   provider: sshpass-1.06-8.ky10.aarch64

package: ansible-2.8.8-1.p01.ky10.noarch
  dependency: /usr/bin/python3
   provider: python3-3.7.9-20.p07.se.ky10.aarch64
  dependency: python(abi) = 3.7
   provider: python3-3.7.9-20.p07.se.ky10.aarch64
  dependency: python3-cryptography
   provider: python3-cryptography-2.9.2-2.ky10.aarch64
  dependency: python3-jinja2
   provider: python3-jinja2-2.11.2-2.p01.ky10.noarch
  dependency: python3-paramiko
   provider: python3-paramiko-2.4.3-1.ky10.ky10.noarch
  dependency: python3-pyyaml
   provider: python3-pyyaml-5.1.2-1.ky10.aarch64
  dependency: python3-setuptools
   provider: python3-setuptools-44.1.1-2.ky10.noarch
  dependency: python3-six
   provider: python3-six-1.12.0-1.ky10.noarch
  dependency: python3.7dist(cryptography)
   provider: python3-cryptography-2.9.2-2.ky10.aarch64
  dependency: python3.7dist(jinja2)
   provider: python3-jinja2-2.11.2-2.p01.ky10.noarch
  dependency: python3.7dist(pyyaml)
   provider: python3-pyyaml-5.1.2-1.ky10.aarch64
  dependency: sshpass
   provider: sshpass-1.06-8.ky10.aarch64

1.2 yum下载依赖包到目录/opt/ansible,并打包

[root@tpcc-armA ~]# yumdownloader ansible  --resolve --destdir=/opt/ansible
Last metadata expiration check: 2:13:21 ago on 2023年11月12日 星期日 08时27分52秒.
(1/11): python3-bcrypt-3.1.4-7.ky10.aarch64.rpm                                                                                44 kB/s |  36 kB     00:00
(2/11): libsodium-1.0.16-7.ky10.aarch64.rpm                                                                                   125 kB/s | 101 kB     00:00
(3/11): python3-paramiko-2.4.3-1.ky10.ky10.noarch.rpm                                                                         2.9 MB/s | 281 kB     00:00
(4/11): python3-pyasn1-0.3.7-8.ky10.noarch.rpm                                                                                4.6 MB/s | 215 kB     00:00
(5/11): python3-pynacl-1.2.1-4.ky10.aarch64.rpm                                                                               1.7 MB/s |  75 kB     00:00
(6/11): python3-markupsafe-1.0-3.ky10.aarch64.rpm                                                                             130 kB/s |  28 kB     00:00
(7/11): python3-pyyaml-5.1.2-1.ky10.aarch64.rpm                                                                               3.8 MB/s | 173 kB     00:00
(8/11): sshpass-1.06-8.ky10.aarch64.rpm                                                                                       351 kB/s |  25 kB     00:00
(9/11): python3-jinja2-2.11.2-2.p01.ky10.noarch.rpm                                                                           654 kB/s | 223 kB     00:00
(10/11): python3-babel-2.7.0-1.ky10.noarch.rpm                                                                                1.2 MB/s | 5.9 MB     00:04
(11/11): ansible-2.8.8-1.p01.ky10.noarch.rpm                                                                                  688 kB/s |  15 MB     00:21
[root@tpcc-armA ~]# cd /opt/ansible/
[root@tpcc-armA ansible]# ll
总用量 22188
-rw-r--r-- 1 root root 15321140 1112 10:41 ansible-2.8.8-1.p01.ky10.noarch.rpm
-rw-r--r-- 1 root root   103700 1112 10:41 libsodium-1.0.16-7.ky10.aarch64.rpm
-rw-r--r-- 1 root root  6189420 1112 10:41 python3-babel-2.7.0-1.ky10.noarch.rpm
-rw-r--r-- 1 root root    36724 1112 10:41 python3-bcrypt-3.1.4-7.ky10.aarch64.rpm
-rw-r--r-- 1 root root   228612 1112 10:41 python3-jinja2-2.11.2-2.p01.ky10.noarch.rpm
-rw-r--r-- 1 root root    29128 1112 10:41 python3-markupsafe-1.0-3.ky10.aarch64.rpm
-rw-r--r-- 1 root root   287484 1112 10:41 python3-paramiko-2.4.3-1.ky10.ky10.noarch.rpm
-rw-r--r-- 1 root root   220644 1112 10:41 python3-pyasn1-0.3.7-8.ky10.noarch.rpm
-rw-r--r-- 1 root root    77260 1112 10:41 python3-pynacl-1.2.1-4.ky10.aarch64.rpm
-rw-r--r-- 1 root root   176804 1112 10:41 python3-pyyaml-5.1.2-1.ky10.aarch64.rpm
-rw-r--r-- 1 root root    25288 1112 10:41 sshpass-1.06-8.ky10.aarch64.rpm
[root@tpcc-armA ansible]# cd ..
[root@tpcc-armA opt]# tar czf ansible.offline.tar.gz ansible/
[root@tpcc-armA opt]#

2.在目标环境Host30使用离线包安装ansible

2.1 上传离线包ansible.offline.tar.gz 到/opt目录并解压

[root@host30 opt]# ll
总用量 418704
-rw-------  1 root  root   20917406 1112 10:46 ansible.offline.tar.gz
drwxr-xr-x  2 root  root         24  531  2021 firefox
-rwx------  1 root  root       1089  228  2023 install_node_exporter.sh
-rw-------  1 root  root   74493117 1027 09:52 jdk1.8.0_331.tar.gz
drwx------  4 root  root         73 1027 11:20 monitor
drwxr-xr-x 11 mysql mysql       305  114  2023 nginx-1.14.2
-rwx------  1 root  root    6589005 111 23:09 nginx-1.14.2.tar.gz
-rw-------  1 root  root    9470305  228  2023 node_exporter-1.5.0.linux-arm64.tar.gz
drwxr-xr-x  4 root  root         58  531  2021 patch_workspace
-rw-------  1 root  root  317264886 1027 09:45 root-jenkins.tar.gz
drwx------  2 root  root       4096 1112 10:46 tar
drwx------  5 root  root        209 1027 09:49 tpcc
[root@host30 opt]# tar xf ansible.offline.tar.gz
[root@host30 opt]# ll
总用量 418708
drwxr-xr-x  2 root  root       4096 1112 10:41 ansible
-rw-------  1 root  root   20917406 1112 10:46 ansible.offline.tar.gz
drwxr-xr-x  2 root  root         24  531  2021 firefox
-rwx------  1 root  root       1089  228  2023 install_node_exporter.sh
-rw-------  1 root  root   74493117 1027 09:52 jdk1.8.0_331.tar.gz
drwx------  4 root  root         73 1027 11:20 monitor
drwxr-xr-x 11 mysql mysql       305  114  2023 nginx-1.14.2
-rwx------  1 root  root    6589005 111 23:09 nginx-1.14.2.tar.gz
-rw-------  1 root  root    9470305  228  2023 node_exporter-1.5.0.linux-arm64.tar.gz
drwxr-xr-x  4 root  root         58  531  2021 patch_workspace
-rw-------  1 root  root  317264886 1027 09:45 root-jenkins.tar.gz
drwx------  2 root  root       4096 1112 10:46 tar
drwx------  5 root  root        209 1027 09:49 tpcc

2.2 制作本地yum源

[root@host30 opt]# cat >/etc/yum.repos.d/ansible.repo<<eof
> [ansible]
> name=ansible
> baseurl=file:///opt/ansible
> gpgcheck=0
> enabled=1
> eof
[root@host30 opt]#
[root@host30 opt]# createrepo /opt/ansible/
Directory walk started
Directory walk done - 11 packages
Temporary output repo path: /opt/ansible/.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
[root@host30 opt]#
[root@host30 opt]# yum clean all
16 files removed
[root@host30 opt]# yum repolist
repo id                                                                        repo name
ansible                                                                        ansible
kylin_arm.repo                                                                 kylin_arm.repo
[root@host30 opt]#

2.3 使用本地yum源安装

[root@host30 opt]# yum install ansible -y
ansible                                                                                                                        73 MB/s |  75 kB     00:00
kylin_x86_64.repo                                                                                                             492 MB/s | 3.8 MB     00:00
Dependencies resolved.
==============================================================================================================================================================
 Package                                    Architecture                    Version                                     Repository                       Size
==============================================================================================================================================================
Installing:
 ansible                                    noarch                          2.8.8-1.p01.ky10                            ansible                          15 M
Installing dependencies:
 libsodium                                  aarch64                         1.0.16-7.ky10                               ansible                         101 k
 python3-babel                              noarch                          2.7.0-1.ky10                                ansible                         5.9 M
 python3-bcrypt                             aarch64                         3.1.4-7.ky10                                ansible                          36 k
 python3-jinja2                             noarch                          2.11.2-2.p01.ky10                           ansible                         223 k
 python3-markupsafe                         aarch64                         1.0-3.ky10                                  ansible                          28 k
 python3-paramiko                           noarch                          2.4.3-1.ky10.ky10                           ansible                         281 k
 python3-pyasn1                             noarch                          0.3.7-8.ky10                                ansible                         215 k
 python3-pynacl                             aarch64                         1.2.1-4.ky10                                ansible                          75 k
 python3-pyyaml                             aarch64                         5.1.2-1.ky10                                ansible                         173 k
 sshpass                                    aarch64                         1.06-8.ky10                                 ansible                          25 k

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

Total size: 22 M
Installed size: 109 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                      1/1
  Installing       : sshpass-1.06-8.ky10.aarch64                                                                                                         1/11
  Installing       : python3-pyyaml-5.1.2-1.ky10.aarch64                                                                                                 2/11
  Installing       : python3-pyasn1-0.3.7-8.ky10.noarch                                                                                                  3/11
  Installing       : python3-markupsafe-1.0-3.ky10.aarch64                                                                                               4/11
  Installing       : python3-bcrypt-3.1.4-7.ky10.aarch64                                                                                                 5/11
  Installing       : python3-babel-2.7.0-1.ky10.noarch                                                                                                   6/11
  Installing       : python3-jinja2-2.11.2-2.p01.ky10.noarch                                                                                             7/11
  Installing       : libsodium-1.0.16-7.ky10.aarch64                                                                                                     8/11
  Installing       : python3-pynacl-1.2.1-4.ky10.aarch64                                                                                                 9/11
  Installing       : python3-paramiko-2.4.3-1.ky10.ky10.noarch                                                                                          10/11
  Installing       : ansible-2.8.8-1.p01.ky10.noarch                                                                                                    11/11
  Running scriptlet: ansible-2.8.8-1.p01.ky10.noarch                                                                                                    11/11
  Verifying        : ansible-2.8.8-1.p01.ky10.noarch                                                                                                     1/11
  Verifying        : libsodium-1.0.16-7.ky10.aarch64                                                                                                     2/11
  Verifying        : python3-babel-2.7.0-1.ky10.noarch                                                                                                   3/11
  Verifying        : python3-bcrypt-3.1.4-7.ky10.aarch64                                                                                                 4/11
  Verifying        : python3-jinja2-2.11.2-2.p01.ky10.noarch                                                                                             5/11
  Verifying        : python3-markupsafe-1.0-3.ky10.aarch64                                                                                               6/11
  Verifying        : python3-paramiko-2.4.3-1.ky10.ky10.noarch                                                                                           7/11
  Verifying        : python3-pyasn1-0.3.7-8.ky10.noarch                                                                                                  8/11
  Verifying        : python3-pynacl-1.2.1-4.ky10.aarch64                                                                                                 9/11
  Verifying        : python3-pyyaml-5.1.2-1.ky10.aarch64                                                                                                10/11
  Verifying        : sshpass-1.06-8.ky10.aarch64                                                                                                        11/11

Installed:
  ansible-2.8.8-1.p01.ky10.noarch         libsodium-1.0.16-7.ky10.aarch64       python3-babel-2.7.0-1.ky10.noarch         python3-bcrypt-3.1.4-7.ky10.aarch64
  python3-jinja2-2.11.2-2.p01.ky10.noarch python3-markupsafe-1.0-3.ky10.aarch64 python3-paramiko-2.4.3-1.ky10.ky10.noarch python3-pyasn1-0.3.7-8.ky10.noarch
  python3-pynacl-1.2.1-4.ky10.aarch64     python3-pyyaml-5.1.2-1.ky10.aarch64   sshpass-1.06-8.ky10.aarch64

Complete!

2.4 安装完成!查看ansible版本信息

[root@host30 opt]# ansible --version
ansible 2.8.8
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.4 (default, Mar 24 2020, 19:20:18) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
[root@host30 opt]#

2.5.修改并查看示例配置文件【 /etc/ansible/hosts】

[root@host30 opt]# tail /etc/ansible/hosts
# Here's another example of host ranges, this time there are no
# leading 0s:

## db-[99:101]-node.example.com
[mysql-servers]
192.168.0.28
192.168.0.36
[mysql-servers:vars]
ansible_ssh_user=root
ansible_ssh_pass='kylin@XXX'
[root@host30 opt]#

2.6.修改配置ansible.cfg

【host_key_checking = False #不检测host key】

[root@host27 ~]# vi /etc/ansible/ansible.cfg

2.7.测试所有机器网络联通性

[root@host30 opt]# ansible mysql-servers -m ping
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

[WARNING]: Platform linux on host 192.168.0.28 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.0.28 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
[WARNING]: Platform linux on host 192.168.0.36 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.0.36 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
[root@host30 opt]#
  • 9
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值