zoukankan      html  css  js  c++  java
  • Ansible离线安装

    Ansible离线安装

    安装环境

    CentOS7.6,Python2.7.5,Ansible2.7.10

    1、Ansible简介:
      Ansible是一个基于Python开发的开源自动化工具,实现了批量运行命令、批量部署程序、批量配置系统等功能。默认通过SSH协议(也可使用其它协议)进行远程命令执行或下发配置,无需部署任何客户端代理软件(agentless)在被管控主机上,并可同时支持多台主机并行管理。Ansible是基于模块工作的,本身没有批量部署的能力,真正具有批量部署的是Ansible所运行的模块,Ansible只是提供一种框架。
    Ansible 2.7官方帮助文档:https://docs.ansible.com/ansible/latest/index.html
    Ansible中文指南:http://www.ansible.com.cn/index.html
    2、版本选择:
      若你希望使用Ansible的最新版本,并且你使用的操作系统是 RHEL、CentOS、Fedora、Debian、Ubuntu,建议使用系统的软件包管理器。
    3、对管理主机的要求:
      目前,只要机器上安装了 Python 2.6 或 Python 2.7 (windows系统不可以做控制主机),都可以运行Ansible。
      主机的系统可以是 Red Hat、Debian、CentOS、OS X、BSD的各种版本,等等。
    4、对托管节点的要求:
      通常我们使用 ssh 与托管节点通信,默认使用 sftp。如果 sftp 不可用,可在 ansible.cfg 配置文件中配置成 scp 的方式。在托管节点上也需要安装 Python 2.4 或以上的版本。如果版本低于 Python 2.5 ,还需要额外安装一个模块:python-simplejson

    在企业环境中,安装ansible的服务器往往不能访问互联网,简单的下载ansible源码安装,会碰到缺少各种依赖包的问题,因此,推荐制作yum源,然后使用yum安装ansible。

    下载离线安装包

    1、准备一台能连接互联网的相同OS服务器,使用yumdownloader工具下载ansible安装包以及所有依赖包。
    以 root 身份安装Yumdownloader工具:
    # yum install yum-utils
    

    ScreenShot209.jpg
    创建离线安装包下载的文件夹:

    # mkdir /root/mypackages
    

    下载yum安装ansible所需的fedora epel源:

    # yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    

    ScreenShot210.jpg
    下载ansible和所有依赖包:

    # yumdownloader --resolve --destdir /root/mypackages/ ansible
    

    ScreenShot211.jpg

    2、将上面下载的所有rpm安装包(/root/mypackages)打包,上传到企业环境的服务器上,解压到创建yum源所需的文件夹里。

    # tar czvf ansible.tar.gz mypackages/    #打包下载的rpm包
    

    通过U盘或网络拷贝到企业环境服务器。

    ansible安装

    1、配置本地CentOS7.6 yum源:

    # mount /dev/cdrom /mnt
    # cp -r /mnt centos76
    # cd /etc/yum.repos.d
    # mkdir bak
    # mv CentOS-* bak
    # vi /etc/yum.repos.d/centos76.repo
    [centos76]
    name=centos76
    baseurl=file:///root/centos76
    gpgcheck=0
    enabled=1
    

    测试本地centos7.6 yum源:

    # yum update
    # yum install vim lrzsz bash-completion
    

    2、上传ansible安装包到yum源:

    # rz    #通过U盘拷贝的,上传打包的rpm文件到服务器
    # tar zxvf ansible.tar.gz
    # mv mypackages/* /root/centos76/Packages/    #剪切rpm文件到已创建的centos源文件夹
    # yum install createrepo
    # yum clean all
    # createrepo /root/centos76    #生成新的yum仓库
    # yum update
    # yum repolist
    # yum list|grep ansible    #查看yum源是否已有ansible安装包
    

    3、安装ansible:

    # yum install ansible
    

    ScreenShot400.jpg

    # ansible --version    #验证安装成功,查看版本号
    

    ScreenShot399.jpg
    注:如果不想创建centos源,可以只下载ansible和createrepo安装包,按照一样的方法创建yum源安装即可。

    # yumdownloader --resolve --destdir /root/mypackages/ createrepo
    

    注:在线安装比较简单,安装epel-release包后,直接运行以下命令即可

    # yum install ansible
    或者使用pip安装:
    # pip install ansible



    wget https://download.pingcap.org/ansible-2.5.0-pip.tar.gz
    wget https://download.pingcap.org/ansible-system-rpms.el7.tar.gz
    tar xzf ansible-system-rpms.el7.tar.gz
    cd ansible-system-rpms.el7/
    ls
    ./install_ansible_system_rpms.sh
    pip -V
    ls
    cd ../
    ls
    tar xzf ansible-2.5.0-pip.tar.gz
    cd ansible-
    cd ansible-2.5.0-pip/
    ls
    cat install_ansible.sh
    ls ansible_offline_packages/
    sh install_ansible.sh
    ls
    cat requirements.txt
    ./install_ansible.sh
    ansible --version
    ansible --help
    ansible --list-hosts
    ansible --list-hosts 192.168.0.1
    ls
    cd ansible_offline_packages/
    ls
    rpm -iUvh http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
    wget http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
    yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    yum install ansible
    ansible --version

     
  • 相关阅读:
    hlgoj 1766 Cubing
    Reverse Linked List
    String to Integer
    Bitwise AND of Numbers Range
    Best Time to Buy and Sell Stock III
    First Missing Positive
    Permutation Sequence
    Next Permutation
    Gray Code
    Number of Islands
  • 原文地址:https://www.cnblogs.com/ipoke/p/11325311.html
Copyright © 2011-2022 走看看