1.ansible运维工具
1.1 ansible介绍

一款系统开发开源的配置和自动化工具,基于python写成类似于saltstack和Puppet。
基于模块工作的,本身没有批量部署的能力,批量部署时运用的是ansible所运行的模块。
ansible只是提供一种框架,通过ssh远程管理受控节点

1.2 ansible架构图

架构:核心Ansible,基于模块工作的,本身没有批量部署的功能,利用运行的模块进行批量部署,只是提供一种框架,通过ssh来远程通讯
Core Modules:自带的模块
Custom Modules:(核心模块功能不足)自定义添加的扩展模块
Plugins:通过插件来实现记录日志,发送邮件或其它功能
Playbooks: 剧本,YAML格式文件,多个任务定义在一个文件中,定义主机需要调用哪些模块来完成的功能
Connectior Plugins: ansible:基于连接插件连接到各个主机上,默认是使用ssh Host Inventory: 记录由Ansible管理的主机信息,包括端口、密码、ip等

2 ansible特点

跨平台支持:Ansible提供linux,windows,UNIX和网络设备的无代理支持,适用于物理,虚拟,容器等
易懂 :ansible playbook采用YAML语言编写,易于阅读
详细描述应用:通过ansible playbook进行更改时,可以描述和记录应用环境的每一个方面
轻松管理版本:Ansible Playbook是纯文本,视作源代码,放在现有版本控制系统中
支持动态清单:从外部源更新Ansible管理的计算机列表,随时获取所有受管服务器的现在的列表,不受影响
利用其它系统集成:利用环境中的HP SA,Puppet,Jenkins,红帽卫星和其它系统,集中到Ansible工作中

3 ansible安装要求
3.1控制主机:linux或UNIX系统

python3.5以上 python2.6以上
centos8.0版本,ansible2.9可以自动使用platform-python包

3.2 受管主机

python 2.6以上或python3.5以上(才可以运行多个模块)
启动了selinux的话 需安装:python3-libselinux包,才能使用复制,文件,模块相关的模块,工作时selinux关闭即可

4.ansible安装

各版本安装详细地址:https://docs.ansible.com/ansible-core/devel/installation_guide/intro_installation.html#prerequisites

#CentOS上安装:
yum -y install epel-release
yum -y install ansible
#rhel上安装:
yum install -y ansible#查看版本信息
[root@localhost ~]# ansible --version
ansible 2.9.23config file = /etc/ansible/ansible.cfgconfigured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules]ansible python module location = /usr/lib/python3.6/site-packages/ansibleexecutable location = /usr/bin/ansiblepython version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

4.1 ansible简单使用

参数:
-m:指定模板名字
-a:命令行参数
-B 后台运行时间
-o:异步
-C 测试脚本能否运行,检查语法
-D 对比文件与上次是否相同,不想同打印
-e 添加额外文件yml
-f 进程数(default=5)
-h, --help show this help message and exit
-i 指定主机目录
-l 指定所有运行的组,ansible all -l test1 -a ping 防止有组之间的继承
-M 指顶模板路径

# 创建一个VVV的用户
[root@localhost project]# ls
ansible.cfg  inventory
[root@localhost project]# ansible localhost -m user -a "name=VVV state=present"
localhost | SUCCESS => {"append": false,"changed": false,"comment": "","group": 1002,"home": "/home/VVV","move_home": false,"name": "VVV","shell": "/bin/bash","state": "present","uid": 1002
}
[root@localhost project]# id VVV
uid=1002(VVV) gid=1002(VVV) 组=1002(VVV)# ansible-doc使用参数
root@localhost project]# ansible-doc -h
usage: ansible-doc [-h] [--version] [-v] [-M MODULE_PATH][--playbook-dir BASEDIR][-t {become,cache,callback,cliconf,connection,httpapi,inventory,lookup,netconf,shell,module,strategy,vars}][-j] [-F | -l | -s | --metadata-dump][plugin [plugin ...]]   # 列出已安装模块
[root@localhost project]# ansible-doc -l
[WARNING]: ipagroup parsing did not produce documentation.
[WARNING]: ipahbacrule parsing did not produce documentation.
[WARNING]: ipahbacsvc parsing did not produce documentation.
[WARNING]: ipahbacsvcgroup parsing did not produce documentation.
[WARNING]: ipahost parsing did not produce documentation.
[WARNING]: ipahostgroup parsing did not produce documentation.
[WARNING]: ipapwpolicy parsing did not produce documentation.
[WARNING]: ipasudocmd parsing did not produce documentation.
[WARNING]: ipasudocmdgroup parsing did not produce documentation.
[WARNING]: ipasudorule parsing did not produce documentation.
[WARNING]: ipatopologysegment parsing did not produce documentation.
[WARNING]: ipatopologysuffix parsing did not produce documentation.
[WARNING]: ipauser parsing did not produce documentation.
a10_server                                                    Manage A10 Networks AX/SoftAX/Thunde...
a10_server_axapi3                                             Manage A10 Networks AX/SoftAX/Thunde...# 查看具体使用模块的方法[root@localhost project]# ansible-doc -s command
- name: Execute commands on targetscommand:argv:                  # Passes the command as a list rather than a string. Use `argv' to avoidquoting values that would otherwise beinterpreted incorrectly (for example"user name"). Only the string or thelist form can be provided, not both.One or the other must be provided.chdir:                 # Change into this directory before running the command.cmd:                   # The command to run.creates:               # A filename or (since 2.0) glob pattern. If it already exists, this step*won't* be run.free_form:             # The command module takes a free form command to run. There is no actualparameter named 'free form'.removes:               # A filename or (since 2.0) glob pattern. If it already exists, this step*will* be run.stdin:                 # Set the stdin of the command directly to the specified value.stdin_add_newline:     # If set to `yes', append a newline to stdin data.strip_empty_ends:      # Strip empty lines from the end of stdout/stderr in result.warn:                  # Enable or disable task warnings.
[root@localhost project]#

ansible架构、安装、简单的使用相关推荐

  1. 《Ansible权威指南》一1.7 Ansible的安装部署

    本节书摘来自华章出版社<Ansible权威指南>一书中的第一章,第1.7节,作者 李松涛 魏 巍 甘 捷 更多章节内容可以访问云栖社区"华章计算机"公众号查看. 1.7 ...

  2. 部署ansible架构

    部署ansible架构 文章目录 部署ansible架构 安装yum源 安装ansible 查看ansible版本 配置/etc/hosts 配置ssh的基于密钥认证 将ansible本地的/etc/ ...

  3. ansible之安装与简单使用

    http://www.ansible.com.cn/:参照中文文档 安装方式:采用epel源安装 a安装epel源: yum install wget wget dl.fedoraproject.or ...

  4. 运维自动化之---ansilbe运维自动化和ansible架构介绍(1)

    运维自动化的发展历程 1.自动化运维应用场景 1.1云计算运维工程师核心职能 运维相关的工具 Podman是用来替代docker的工具 1.2 运维职业的发展路线 目标::一切皆自动化 1.3 企业实 ...

  5. Ansible的安装及使用

    ansible简介 ansible是一种自动化运维工具,基于paramiko开发的,并且基于模块化工作,Ansible是一种集成IT系统的配置管理.应用部署.执行特定任务的开源平台. 它是基于pyth ...

  6. 自动化运维工具ansible的安装管理以及模块介绍

    自动化运维工具ansible的安装管理以及模块介绍 目录 自动化运维工具ansible的安装管理以及模块介绍 一.ansible概述 1.几种常用运维工具比较 2.Ansible简介 3.Ansibl ...

  7. ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建

    文章目录 ansible自动化运维详解(一)ansible的安装部署.参数使用.清单管理.配置文件参数及用户级ansible操作环境构建 一.ansible的安装部署 1.1.ansible简介 1. ...

  8. 自动化运维工具ansible(安装与模块介绍)

    自动化运维工具ansible(安装与模块介绍) 一.ansible运维工具概述 (一).ansible的特点 (二).ansible的原理 (三)ansible的优点 二.安装ansible 三.an ...

  9. ANSIBLE的安装和常用模块使用详细教程

    ANSIBLE安装和各种模块应用功能 文章目录 ANSIBLE安装和各种模块应用功能 安装配置ANSIBLE ANSIBLE使用 ansible-galaxy工具 ansible-pull工具 ans ...

最新文章

  1. linux命令的使用实验报告,Linux实验报告一-常用命令使用.doc
  2. Guava库学习:学习Collections(二)Lists
  3. python xml模块
  4. TensorFlow2简单入门-单词嵌入向量
  5. paho mqtt client调试记录
  6. 求素数的方法完整归纳,学的不仅是“求素数”!
  7. java char判断相等_【Java面试考点4】java基础之运算符
  8. Mybatis之设计模式之装饰者模式
  9. 内置函数补充 之 反射
  10. 配置监控中心-及管理平台
  11. 【健康生活】Google、百度之间的选择
  12. mysql 数据库中根据当前系统时间,取前后几秒 几分钟 几小时 几天
  13. nodejs,python,sublime和Eclipse的包管理器 1
  14. 2022美国大学生数学建模竞赛D题思路
  15. HTML5 - 搭建移动Web应用
  16. VS2013配置PDFLib 9.1.2的环境
  17. win10/win7安装Rational Rose 2007(解决虚拟光驱加载不了bin文件问题)
  18. 斐波那契堆(Fibonacci Heap)
  19. 【单片机小白屑作】基于清翔QX-MCS51单片机的精简版定时炸弹
  20. 教你如何看headers

热门文章

  1. Python深度学习-ch5深度学习用于计算机视觉
  2. ​力扣解法汇总522-最长特殊序列 II
  3. Python基础数据类型详解:字典(补充)
  4. g711原理pcm转alaw,pcm转ulaw,alaw转pcm,ulaw转pcm
  5. 低成本VR手套Lucid再升级,利用柔性齿条来提升手势追踪
  6. greenDao3 0使用小结
  7. 【PC工具】可能是最好用最方便的内部网络设备查看工具,内网ip查询ip扫描工具...
  8. python函数中的嵌套函数
  9. SQL Server 2019企业版和标准版的区别?
  10. Windows系统安装之 BIOS篇(AMI BIOS)