zoukankan      html  css  js  c++  java
  • ansible运维自动化工具

    ansible分为管理主机和托管主机

    安装管理主机:

    一、安装需要的工具。

    yum install -y make automake autoconf gcc gcc-c++ libtools python-dev python-setuptools pip

    二、下载ansible的最新版本

    git clone git://github.com/ansible/ansible.git

    三、编译&&安装

    cd ansible
    make
    make install

    报错处理1:

    File "packaging/release/versionhelper/version_helper.py", line 9, in <module>     from packaging.version import Version, VERSION_PATTERN

    处理方法:

    pip install packaging

    报错处理2:

    Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

    处理方法:

    pip install packaging --ignore-install

    四、配置文件

    两个核心文件:ansible.cfg和hosts文件,默认都存放在/etc/ansible目录下。

    ansible.cfg:主要设置一些ansible初始化的信息,比如日志存放路径、模块、插件等配置信息

    hosts:机器清单,进行分组管理

    拷贝配置文件至指定目录

    mkdir /etc/ansible
    cp -r examples/* /etc/ansible/

    配置文件介绍:

    [defaults]   --->通用默认配置
    
    # some basic default values...
    
    inventory      = /etc/ansible/hosts     这个是默认库文件位置,脚本,或者存放可通信主机的目录
    #library        = /usr/share/my_modules/   Ansible默认搜寻模块的位置
    remote_tmp     = $HOME/.ansible/tmp   Ansible 通过远程传输模块到远程主机,然后远程执行,执行后在清理现场.在有些场景下,你也许想使用默认路径希望像更换补丁一样使用
    pattern        = *    如果没有提供“hosts”节点,这是playbook要通信的默认主机组.默认值是对所有主机通信
    forks          = 5    在与主机通信时的默认并行进程数 ,默认是5d
    poll_interval  = 15    当具体的poll interval 没有定义时,多少时间回查一下这些任务的状态, 默认值是5秒
    sudo_user      = root   sudo使用的默认用户 ,默认是root
    #ask_sudo_pass = True   用来控制Ansible playbook 在执行sudo之前是否询问sudo密码.默认为no
    #ask_pass      = True    控制Ansible playbook 是否会自动默认弹出密码
    transport      = smart   通信机制.默认 值为’smart’。如果本地系统支持 ControlPersist技术的话,将会使用(基于OpenSSH)‘ssh’,如果不支持讲使用‘paramiko’.其他传输选项包括‘local’, ‘chroot’,’jail’等等
    #remote_port    = 22    远程SSH端口。 默认是22
    module_lang    = C   模块和系统之间通信的计算机语言,默认是C语言

    参考链接:

    https://blog.51cto.com/lixcto/1431247

    https://blog.csdn.net/learner198461/article/details/83444187

    https://www.cnblogs.com/LuisYang/p/5960660.html

  • 相关阅读:
    Windows API的CreateFile()中的OPEN_ALWAYS和CREATE_ALWAYS之间的差异
    Linux下的虚拟串口对(可用于在本机上模拟串口进行调试)
    [转&精]IO_STACK_LOCATION与IRP的一点笔记
    【转】在WIN7、WIN10操作系统用WebDAV映射网络驱动器需要的操作
    Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
    分布式处理大数据的目录及学习树
    利用docker将传统企业集中式架构转换为微服务架构的实践经验
    docker学习笔记5 端口映射与容器互联
    docker学习笔记4 数据管理、持久化
    docker学习笔记3 容器 container
  • 原文地址:https://www.cnblogs.com/xulingjie/p/10476359.html
Copyright © 2011-2022 走看看