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

    环境:centos7

    1、离线包下载并配置yum

    #下载离线包 
    yum -y install --downloadonly --downloaddir=/tmp/ans ansible
    #安装createrepo命令
     yum install createrepo
    #将该目录制作成软件仓库
     createrepo /tmp/ans/   
    #压缩文件
     tar -czvf ansible.tar.gz ans
    

    2、安装服务器上进行安装

    文件下载:https://pan.baidu.com/s/10WXmh6bP8KhT3noo4UghMQ 提取码: ncw6 
    #解压文件到指定目录
     tar -zxvf ansible.tar.gz -C /wj/
     #配置yum.repo
     cat > /etc/yum.repos.d/ansible.repo << EOF
     [ans]
     name=ans
     baseurl=file:///wj/ans
     enabled=1
     gpgcheck=0
     EOF
     yum clean all
     #安装ansible
     yum -y install ansible
     #查看版本
     ansible --version
    
     命令
     ansible '*' -m ping
     ansible tidb -a 'date'
     ansible all -a 'df -h /'
    

    3、配置管理及使用

    nsible软件管理配置文件
    vim /etc/ansible/hosts    #定义ansible可管理的主机
    [george]
    172.16.1.7
    172.16.1.31
    172.16.1.41
    --
    进行ansible软件批量管理:
    ansible george -m command -a "uptime" 
    PS: 查看的是george主机组,模块为command,的主机负载信息
     george  #主机组
    -m  #指定模块参数(command为默认模块,不写也可以)
    command #模块名称
    -a  #指定利用模块执行的动作参数,-a后面的是要执行的命令
    uptime #批量执行的命令
    --
    Ansible修改自定义端口和登录用户  
    [servers]
    host1 ansible_ssh_host=192.0.2.1 ansible_ssh_port=5555 ansible_ssh_user="user"
    

      

      

      

      

  • 相关阅读:
    五:系统及数据库
    四:WEB源码扩展
    三:搭建安全拓展
    二:数据包扩展
    一:基础入门-概念名词
    LeetCode 11. Container With Most Water
    LeetCode 263. Ugly Number
    LeetCode 10. Regular Expression Matching
    LeetCode 58. Length of Last Word
    LeetCode 53. Maximum Subarray
  • 原文地址:https://www.cnblogs.com/wukc/p/14298246.html
Copyright © 2011-2022 走看看