ansible功能

  • 批量执行远程命令,可以对远程的多台主机同时进行命令的执行
  • 批量安装和配置软件服务,可以对远程的多台主机进行自动化的方式配置和管理各种服务
  • 编排高级的企业级复杂的IT架构任务, Ansible的Playbook和role可以轻松实现大型的IT复杂架构
  • 提供自动化运维工具的开发API, 有很多运维工具,如jumpserver(堡垒机)就是基于 ansible 实现自动化管理功能

ansible特性

 - 模块化:调用特定的模块完成特定任务,支持自定义模块,可使用任何编程语言写模块c账号,软件等)
- Paramiko(python对ssh的实现),PyYAML,Jinja2(模板语言)三个关键模块
- 基于Python语言实现
- 部署简单,基于python和SSH(默认已安装),agentless,无需代理不依赖PKI(无需ssl)
- 安全,基于OpenSSH
- 幂等性:一个任务执行1遍和执行n遍效果一样,不因重复执行带来意外情况,此特性非绝对
- 支持playbook编排任务,YAML格式,编排任务,支持丰富的数据结构   剧本演员要按照    系统按照你规定的方式去执行命令
- 较强大的多层解决方案 role

 ansible组成

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器

ansible安装 

1.编译安装

yum -y install python-jinja2 PyYAML python-paramiko python-babel python-crypto
wget https://releases.ansible.com/ansible/ansible-1.5.4.tar.gz
tar xf ansible-1.5.4.tar.gz
cd ansible-1.5.4
python setup.py build
python setup.py install
mkdir /etc/ansible
cp -r examples/* /etc/ansible

2.yum源安装

[root@node1 yum.repos.d]#vim CentOS-Base.repo 
#加入 epel源
[epel]
name=gn
baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64
        https://mirrors.cloud.tencent.com/epel/$releasever/x86_64
        https://mirrors.huaweicloud.com/epel/$releasever/x86_64
        https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/x86_64
gpgcheck=0


[root@node1 yum.repos.d]#yum info  ansible
已加载插件:fastestmirror, langpacks
base                                                                                | 3.6 kB  00:00:00     
epeel                                                                               | 4.7 kB  00:00:00     
extras                                                                              | 2.9 kB  00:00:00     
updates                                                                             | 2.9 kB  00:00:00     
(1/3): epeel/7/group_gz                                                             |  96 kB  00:00:00     
(2/3): epeel/7/updateinfo                                                           | 1.0 MB  00:00:00     
(3/3): epeel/7/primary_db                                                           | 7.0 MB  00:00:04     
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epeel: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
可安装的软件包
名称    :ansible
架构    :noarch
版本    :2.9.25
发布    :1.el7
大小    :17 M
源    :epeel/7
简介    : SSH-based configuration management, deployment, and task execution system
网址    :http://ansible.com
协议    : GPLv3+
描述    : Ansible is a radically simple model-driven configuration management,
         : multi-node deployment, and remote task execution system. Ansible works
         : over SSH and does not require any software or daemons to be installed
         : on remote nodes. Extension modules can be written in any language and
         : are transferred to managed machines automatically.



[root@node1 yum.repos.d]#yum install ansible -y
......................省略..................................
已安装:
  ansible.noarch 0:2.9.25-1.el7                                                                            

作为依赖被安装:
  PyYAML.x86_64 0:3.10-11.el7                          libyaml.x86_64 0:0.1.4-11.el7_0                    
  python-babel.noarch 0:0.9.6-8.el7                    python-jinja2.noarch 0:2.7.2-4.el7                 
  python-markupsafe.x86_64 0:0.11-10.el7               python-paramiko.noarch 0:2.1.1-9.el7               
  python2-httplib2.noarch 0:0.18.1-3.el7               python2-jmespath.noarch 0:0.9.4-2.el7              

完毕!

 3.yum安装

yum install epel-release.noarch  -y
yum install ansible -y

 这边不需要安装客户端,因为ansible服务端通过ssh协议,将py脚本传到客户端,然后客户端通过此脚本协议去操作!!!!

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_02

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_03

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_04

主配置文件里面的内容:

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_05

 

清单文件:

ansible的主要功用在于批量主机操作,为了便捷地使用其中的部分主机,可以在inventory 主机清单文件中将其分组组织

ansible when 上一个step执行状态 ansible有哪些执行模式_python_06

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_07


ansible when 上一个step执行状态 ansible有哪些执行模式_网络_08

 

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_09

ansible用法

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_10

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_11

ansible --version 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_12

 ansible -C 是检查脚本错误

ansible -f 是指定并发处理的数量

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_13

 举例说明: 在做ansible之前,要做ssh

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_14

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_15

 --list 可以显示当前主机   all--list 显示所有主机

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_16

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_17

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_18

 因为,没登录一次都要输入yes 跟密码 为了方便,要设置免登录ssh

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_19

有两种方法,去掉ssh连接的yes

1. 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_20

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_21

然后拿ssh验证

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_22

 

2.修改ansible的配置文件

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_23

ansible when 上一个step执行状态 ansible有哪些执行模式_python_24

 随后保存,拿ansible验证

ansible when 上一个step执行状态 ansible有哪些执行模式_python_25

 

 免密登录:

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub

ansible when 上一个step执行状态 ansible有哪些执行模式_python_26

 

ansible when 上一个step执行状态 ansible有哪些执行模式_python_27

最后验证一下,成功

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_28

然后拿ansible用一下啥也,密码跟yes都不用输入 web是写在清单里面的组名

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_29

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_30

playbook

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_31

 

 模块

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_32

 command模块

功能:在远程主机执行命令,此为默认模块,可忽略 -m 选项

注意:此命令不支持 $VARNAME < >(标准输出) | ; &(后台) 等,可能用shell模块实现

注意:此模块不具有幂等性

ansible when 上一个step执行状态 ansible有哪些执行模式_python_33

或者去客户端查看

 客户端7-4

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_34

客户端7-3 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_35

 

command不支持 < > &等,可以实验看一下   shell模块比command模块功能强

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_36

 

随后,进入到客户端/data/test1中查看

ansible when 上一个step执行状态 ansible有哪些执行模式_python_37

 

如果想将默认模块改为shell,要在ansible主配置文件里面修改

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_38

 

ansible when 上一个step执行状态 ansible有哪些执行模式_python_39

此时,如果不写-m模块,再次查看一下

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_40

 然后进入客户端查看,

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_41

shell模块(上面有shell模块演示)

功能:和command相似,用shell执行命令,支持各种符号,比如:*,$, >

注意:此模块不具有幂等性

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_42

 script模块

功能:在远程主机上运行ansible服务器上的脚本(无需执行权限)

注意:此模块不具有幂等性

就是在主机上面写脚本,然后让客户机去执行

举例:

写一个hello.sh的脚本文件

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_43

在opt下面新建data的文件夹 

ansible when 上一个step执行状态 ansible有哪些执行模式_python_44

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_45

 随后,在客户端检测

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_46

 

copy模块

功能:从ansible服务器主控端复制文件到远程主机

注意: src=file 如果是没指明路径,则为当前目录或当前目录下的files目录下的file文件

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_47

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_48

 如果要指明的用户,在客户端必须有这个客户

实验操作:

在7-3客户端上新建lisi用户

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_49

在7-4客户端上新建lisi用户

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_50

 

 服务端操作

ansible when 上一个step执行状态 ansible有哪些执行模式_python_51

随后,去客户端mnt下面看一下,有fatsb这个文件

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_52

 

ansible when 上一个step执行状态 ansible有哪些执行模式_python_53

实验2

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_54

 

随后,去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_55

 

backup 备份,源文件要是有改动的情况下就会有备份的

例如,修改此脚本文件

ansible when 上一个step执行状态 ansible有哪些执行模式_python_56

 

然后再执行相同的命令

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_57

 再去客户端访问mnt,此时就会有备份的

ansible when 上一个step执行状态 ansible有哪些执行模式_python_58

注意点!!

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_59

当etc不讲/时,表明整个etc都复制进去

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_60

 去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_61

当etc加/时

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_62

 去客户端查看,将etc下面的子文件全部复制到mnt下面了,就是将etc改名为mnt

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_63

 content 指定文件内容

例如:

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_64

然后去客户端查看,去tmp下面查看

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_65

 

 

 Get_url模块

功能: 用于将文件从http、https或ftp下载到被管理机节点上

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_66

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_67

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_68

去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_69

 

检测nginx是否有问题  md5sum

ansible when 上一个step执行状态 ansible有哪些执行模式_python_70

 

 Fetch模块,只能传文件,不支持文件夹

功能:从远程主机提取文件至ansible的主控端,copy相反,目前不支持目录 ,就是将客户端的东西,弄到服务器去使用

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_71

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_72

 File模块

功能:设置文件属性,创建软链接等

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_73

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_74

 

创建空文件:

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_75

随后,去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_76

 

创建文件夹/目录

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_77

 

去客户端访问

ansible when 上一个step执行状态 ansible有哪些执行模式_python_78

 

stat模块

功能:检查文件或文件系统的状态

注意:对于Windows目标,请改用win_stat模块

 path:文件/对象的完整路径(必须)

常用的返回值判断

exists: 判断是否存在
isuid: 调用用户的ID与所有者ID是否匹配

如果存在会有大量的信息出来,如果不存在,会跳出false如下图 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_79

 

这是存在的页面 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_80

 

unarchive 模块

 功能:解包解压缩

实现有两种用法:

1、将ansible主机上的压缩包传到远程主机后解压缩至特定目录,设置copy=yes,此为默认值,可省略

2、将远程主机上的某个压缩包解压缩到指定路径下,设置copy=no

参数: 

copy:默认为yes,当copy=yes,拷贝的文件是从ansible主机复制到远程主机上,如果设置为copy=no,会在远程主机上寻找src源文件  
remote_src:和copy功能一样且互斥,yes表示在远程主机,不在ansible主机,no表示文件在ansible主机上
src:源路径,可以是ansible主机上的路径,也可以是远程主机(被管理端或者第三方主机)上的路径,如果是远程主机上的路径,则需要设置copy=no
dest:远程主机上的目标路径
mode:设置解压缩后的文件权限 

 copy=yes:

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_81

 第一步 先解压所有的包

ansible when 上一个step执行状态 ansible有哪些执行模式_python_82

 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_83

然后去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_84

 

 

copy=no 意思是src是在远程客户端上面的原路径,而不是非服务器主机的原路径

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_85

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_86

 

 然后去客户端查看,客户端解压好了

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_87

 

Archive模块

功能:打包压缩保存在被管理节点  

对远端机器进行压缩,是将远端客户机上面的压缩到远端上

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_88

 然后进客户端进行查看

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_89

 

Hostname模块

功能:管理主机名

ansible 192.168.91.102 -m hostname -a 'name=node3 '
#一般不使用此模块,主机名会一致 

 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_90

去客户机查看

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_91

 

 cron模块

功能:计划任务

支持时间:minute,hour,day,month,weekday

 关键字

name  会生成一行注释,显示标题如下显示
job   执行的命令

ansible when 上一个step执行状态 ansible有哪些执行模式_python_92

 随后,去192.168.68.6的客户端查看计划任务 crontab -l

ansible when 上一个step执行状态 ansible有哪些执行模式_python_93

 删除计划任务  state=absent

ansible when 上一个step执行状态 ansible有哪些执行模式_python_94


 

 然后去客户端查看,此时没有计划任务了

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_95

 disable=yes  表示禁用 计划任务

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_96

然后去客户端查看,被注释了

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_97

 

 disabled=no,表示开启计划任务,而非开启名字注释

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_98

去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_python_99

 

Yum和 Apt 模块

功能:yum 管理软件包,只支持RHEL,CentOS,fedora,不支持Ubuntu其它版本apt 模块管理 Debian 相关版本的软件包

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_100

ansible websrvs -m yum -a 'name=httpd state=present'  #安装
ansible websrvs -m yum -a 'name=nginx state=present enablerepo=epel'  #启用epel源
进行安装
ansible websrvs -m yum -a 'name=* state=lastest exclude=kernel*,foo*' #升级除
kernel和foo开头以外的所有包
ansible websrvs -m yum -a 'name=httpd state=absent'   #删除



ansible 192.168.91.101 -m yum -a "name=tree"

 

 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_101

去客户端查看是否安装了httpd ,成功下载

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_102

 

 卸载 state=absent

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_103

然后去客户端查看

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_104

 

 

 下载nginx

ansible when 上一个step执行状态 ansible有哪些执行模式_python_105

 去客户端

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_106

yum_repository 模块

功能:建立yum仓库模块

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_107

 

ansible web -m yum_repository -a 'name=epel description=epel  baseurl=https://download.fedoraproject.org/pub/epel/$releasever/$basearch/ gpgcheck=no file=epel'





- name: Add multiple repositories into the same file (1/2)
 yum_repository:
   name: epel
   description: EPEL YUM repo
   file: external_repos
   baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/

ansible when 上一个step执行状态 ansible有哪些执行模式_python_108

 

 service模块

功能:管理服务

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_109

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_110

 随后在本机查看,nginx开启

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_111

 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_112

 

mount 挂载和卸载

功能: 挂载和卸载文件系统

#临时挂载
mount websrvs -m mount -a 'src="UUID=b3e48f45-f933-4c8e-a700-22a159ec9077" path=/home fstype=xfs opts=noatime state=present'
#临时取消挂载
mount websrvs -m mount -a 'path=/home fstype=xfs opts=noatime state=unmounted'
#永久挂载
ansible websrvs -m mount -a 'src=10.0.0.8:/data/wordpress path=/var/www/html/wp-content/uploads opts="_netdev" state=mounted'
#永久卸载
ansible websrvs -m mount -a 'src=10.0.0.8:/data/wordpress path=/var/www/html/wp-content/uploads state=absent'

其中uid怎么查找

ansible when 上一个step执行状态 ansible有哪些执行模式_ansible_113

 

 user模块

功能:管理用户

comment         用户的描述信息
createhome      是否创建家目录
force           在使用state=absent时, 行为与userdel –force一致.
group           指定基本组
groups          指定附加组,如果指定为(groups=)表示删除所有组
home            指定用户家目录
move_home       如果设置为home=时, 试图将用户主目录移动到指定的目录
name            指定用户名
non_unique      该选项允许改变非唯一的用户ID值
password        指定用户密码,使用 SHA512 hash
remove          在使用state=absent时, 行为是与userdel –remove一致
shell           指定默认shell
state           设置帐号状态,不指定为创建,指定值为absent表示删除
system          当创建一个用户,设置这个用户是系统用户。这个设置不能更改现有用户
uid             指定用户的uid
update_ password 
  always      如果password参数设置的值与用户当前的加密过的密码字符串不一致,则直接更新用户的密码,默认值即为always
  on_create   如果password参数设置的值与用户当前的加密过的密码字符串不一致,则不会更新用户的密码字符串,保持之前的密码设定

 举例:

#创建用户
ansible all -m user -a 'name=user1 comment="test user" uid=2048 home=/app/user1 group=root‘
Group 模块

功能:管理组

#创建组
ansible websrvs -m group  -a 'name=nginx gid=88 system=yes'
#删除组
ansible websrvs -m group  -a 'name=nginx state=absent'
Lineinfile 模块

ansible在使用sed进行替换时,经常会遇到需要转义的问题,而且ansible在遇到特殊符号进行替换时,存在问题,无法正常进行替换 。其实在ansible自身提供了两个模块:lineinfile模块和replace模块,可以方便的进行替换一般在ansible当中去修改某个文件的单行进行替换的时候需要使用lineinfile模块

regexp参数 :使用正则表达式匹配对应的行,当替换文本时,如果有多行文本都能被匹配,则只有最后面被匹配到的那行文本才会被替换,当删除文本时,如果有多行文本都能被匹配,这么这些行都会被删除。

如果想进行多行匹配进行替换需要使用replace模块

功能:相当于sed,可以修改文件内容

 

ansible when 上一个step执行状态 ansible有哪些执行模式_客户端_114

 举例

ansible web -m lineinfile -a "path=/etc/httpd/conf/httpd.conf regexp='^Listen' line='Listen 80'" regexp为查找的意思 line为替换的意思

ansible all -m   lineinfile -a "path=/etc/selinux/config regexp='^SELINUX=' line='SELINUX=disabled'"

ansible all -m lineinfile  -a 'dest=/etc/fstab state=absent regexp="^#"'

 

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_115

replace 模块

该模块有点类似于sed命令,主要也是基于正则进行匹配和替换,建议使用

 

ansible all -m replace -a "path=/etc/fstab regexp='^(UUID.*)' replace='#\1'"  

ansible all -m replace -a "path=/etc/fstab regexp='^#(UUID.*)' replace='\1'"


ansible web -m replace -a "path=/etc/httpd/conf/httpd.conf regexp='^Listen.*' line='Listen 80'"

ansible when 上一个step执行状态 ansible有哪些执行模式_python_116

 

去客户机查看

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_117

 

setup模块

功能: setup 模块来收集主机的系统信息,这些 facts 信息可以直接以变量的形式使用,但是如果主机较多,会影响执行速度

可以使用 gather_facts: no 来禁止 Ansible 收集 facts 信息

范例:

ansible all -m setup
ansible all -m setup -a "filter=ansible_nodename"
ansible all -m setup -a "filter=ansible_hostname"
ansible all -m setup -a "filter=ansible_domain"
ansible all -m setup -a "filter=ansible_memtotal_mb"
ansible all -m setup -a "filter=ansible_memory_mb"
ansible all -m setup -a "filter=ansible_memfree_mb"
ansible all -m setup -a "filter=ansible_os_family"
ansible all -m setup -a "filter=ansible_distribution_major_version"
ansible all -m setup -a "filter=ansible_distribution_version"
ansible all -m setup -a "filter=ansible_processor_vcpus"
ansible all -m setup -a "filter=ansible_all_ipv4_addresses"
ansible all -m setup -a "filter=ansible_architecture"
ansible all -m setup -a "filter=ansible_uptime_seconds"
ansible all -m setup -a "filter=ansible_processor*"
ansible all -m setup -a 'filter=ansible_env'

 

ansible相关工具

- /usr/bin/ansible                     主程序,临时命令执行工具
- /usr/bin/ansible-doc              查看配置文档,模块功能查看工具,相当于man  ansible-doc -l |grep 关键字 具体模块名字   
- /usr/bin/ansible-playbook    定制自动化任务,编排剧本工具,相当于脚本
- /usr/bin/ansible-pull              远程执行命令的工具
- /usr/bin/ansible-vault           文件加密工具
- /usr/bin/ansible-console      基于Console界面与用户交互的执行工具
- /usr/bin/ansible-galaxy        下载/上传优秀代码或Roles模块的官网平台

  

 ansible-doc -l 列出所有模块

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_118

一共有3387个模块 

ansible when 上一个step执行状态 ansible有哪些执行模式_网络_119

 ansible-doc 后面加模块,可以显示当前模块的用法

ansible when 上一个step执行状态 ansible有哪些执行模式_服务器_120

如果想看简略的用法 在模块前面加上-s

ansible when 上一个step执行状态 ansible有哪些执行模式_python_121