Ansible在线安装详细教程

Ansible在线安装详细教程,第1张

  1. 软件环境
    CentOS Linux release 7.9.2009 (Core)
    Linux主机需要连接互联网,具体设置请参考 Linux虚拟机联网设置详细教程

  2. 目标
    指向官方的epel源,安装ansible

  3. 什么是epel源
    EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的 *** 作系统提供额外的软件包,适用于RHEL、CentOS。

  4. 安装OS版本对应的epel-release软件包,这个软件包会自动配置yum的软件仓库。

    https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 适用于Centos7版本,点击链接,下载软件包,并上传到目标主机/tmp目录。

    [root@client ~]# cd /tmp
    [root@client tmp]# ls
    epel-release-latest-7.noarch.rpm  vmware-root_691-4013264459  vmware-root_692-2696942994  vmware-root_722-2966037965
    [root@client tmp]# rpm -ivh epel-release-latest-7.noarch.rpm
    warning: epel-release-latest-7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:epel-release-7-14                ################################# [100%]
    [root@client tmp]# cd /etc/yum.repos.d/
    #2.看到yum.repos.d目录下生成了epep.repo文件,指向了官方epel源
    [root@client yum.repos.d]# ls
    bak  epel.repo  epel-testing.repo  http.repo
    
  5. 清除当前的yum缓存

    [root@client yum.repos.d]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: base epel
    Cleaning up list of fastest mirrors
    Other repos take up 118 M of disk space (use --verbose for details)
    [root@client yum.repos.d]#
    
  6. 安装ansible软件

    [root@client yum.repos.d]# yum install ansible -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * epel: hk.mirrors.thegigabit.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package ansible.noarch 0:2.9.27-1.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==============================================================================================================================================================================================================
    Package                                          Arch                                            Version                                                 Repository                                     Size
    ==============================================================================================================================================================================================================
    Installing:
    ansible                                          noarch                                          2.9.27-1.el7                                            epel                                           17 M
    
    Transaction Summary
    ==============================================================================================================================================================================================================
    Install  1 Package
    
    Total download size: 17 M
    Installed size: 103 M
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/epel/packages/ansible-2.9.27-1.el7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY===================================-  ] 1.3 MB/s |  17 MB  00:00:00 ETA
    Public key for ansible-2.9.27-1.el7.noarch.rpm is not installed
    ansible-2.9.27-1.el7.noarch.rpm                                                                                                                                                        |  17 MB  00:00:16
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    Importing GPG key 0x352C64E5:
    Userid     : "Fedora EPEL (7) "
    Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
    Package    : epel-release-7-14.noarch (installed)
    From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Warning: RPMDB altered outside of yum.
     Installing : ansible-2.9.27-1.el7.noarch                                                                                                                                                                1/1
     Verifying  : ansible-2.9.27-1.el7.noarch                                                                                                                                                                1/1
    
    Installed:
     ansible.noarch 0:2.9.27-1.el7
    
    Complete!
    [root@client yum.repos.d]#
    
    
  7. 查看并验证Ansible的版本

    [root@client yum.repos.d]# ansible --version
    ansible 2.9.27
      config file = /etc/ansible/ansible.cfg
      configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
      ansible python module location = /usr/lib/python2.7/site-packages/ansible
      executable location = /usr/bin/ansible
      python version = 2.7.5 (default, Oct 14 2020, 14:45:30) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
    

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/733445.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存