自动化运维工具Ansible实战(四)常用模块
转载链接:http://blog.51cto.com/liqingbiao/1962609
Ansible模块按功能分为:云模块、集群模块、 命令模块、数据库模块、文件模块、资产模块、消息模块、监控模块、网络模块、通知模块、包管理模块、源码控制模块、系统模块、单元模块、web设施模块、windows模块 具体的可以参考官网(http://docs.ansible.com/ansible/latest/list_of_all_modules.html)。这里从官方分类的模块里选择最常用的一些模块进行介绍。
1,ping模块。测试主机是否是通的
|
1
2
3
4
5
6
7
8
9
|
[root@Monitor ansible]# ansible web1 -m pingServer5 | SUCCESS => { "changed": false, "ping": "pong"}Server6 | SUCCESS => { "changed": false, "ping": "pong"} |
2,远程命令模块
|
1
2
3
|
ansible webserver -m command -a "free -m" #远程命令。ansible webserver -m script -a "/home/test.sh" #远程主机执行主控服务器ansible上的脚本ansible webserver -m shell -a "/home/test.sh" #执行远程主机上的脚本命令 |
3,setup模块。主要用于获取主机信息,在playbooks里经常会用到的一个参数,gather_facts就与该模块相关。setup模块下经常使用的一个参数是filter参数
|
1
2
3
|
ansible 10.212.52.252 -m setup -a 'filter=ansible_*_mb' //查看主机内存信息ansible 10.212.52.252 -m setup -a 'filter=ansible_eth[0-2]' //查看地接口为eth0-2的网卡信息ansible all -m setup --tree /tmp/facts //将所有主机的信息输入到/tmp/facts目录下,每台主机的信息输入到主机名文件中(/etc/ansible/hosts里的主机名) |
4,stat模块。获取远程文件状态信息,包括atime、ctime、mtime、MD5、uid、gid等信息
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
[root@Monitor ansible]# ansible 192.168.180.5 -m stat -a "path=/etc/sysctl.conf "192.168.180.5 | SUCCESS => { "changed": false, "stat": { "atime": 1504513902.6297896, "checksum": "a27c7ce2e6002c37f3cb537ad997c6da7fd76480", "ctime": 1480926522.4591811, "dev": 64768, "executable": false, "exists": true, "gid": 0, "gr_name": "root", "inode": 393634, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "md5": "c97839af771c8447b9fc23090b4e8d0f", "mode": "0644", "mtime": 1361531931.0, "nlink": 1, "path": "/etc/sysctl.conf", "pw_name": "root", "readable": true, "rgrp": true, "roth": true, "rusr": true, "size": 1150, "uid": 0, "wgrp": false, "woth": false, "writeable": true, "wusr": true, "xgrp": false, "xoth": false, "xusr": false }} |
5,file模块。file模块主要用于远程主机上的文件操作,file模块包含如下选项:
force:需要在两种情况下强制创建软链接,一种是源文件不存在但之后会建立的情况下;另一种是目标软链接已存在,需要先取消之前的软链,然后创建新的软链,有两个选项:yes|no
group:定义文件/目录的属组
mode:定义文件/目录的权限
owner:定义文件/目录的属主
path:必选项,定义文件/目录的路径
recurse:递归的设置文件的属性,只对目录有效
src:要被链接的源文件的路径,只应用于state=link的情况
dest:被链接到的路径,只应用于state=link的情况
state:
directory:如果目录不存在,创建目录
file:即使文件不存在,也不会被创建
link:创建软链接
hard:创建硬链接
touch:如果文件不存在,则会创建一个新的文件,如果文件或目录已存在,则更新其最后修改时间
absent:删除目录、文件或者取消链接文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
[root@Monitor ansible]# ansible 192.168.180.6 -m file -a "src=/etc/fstab dest=/tmp/fstab state=link" ########在远程主机180.6上创建远程软连接192.168.180.6 | SUCCESS => { "changed": true, "dest": "/tmp/fstab", "gid": 0, "group": "root", "mode": "0777", "owner": "root", "size": 10, "src": "/etc/fstab", "state": "link", "uid": 0}[root@Monitor ansible]# ansible 192.168.180.6 -m file -a "path=/tmp/test state=touch" ############在远程主机180.6上创建test文件192.168.180.6 | SUCCESS => { "changed": true, "dest": "/tmp/test", "gid": 0, "group": "root", "mode": "0644", "owner": "root", "size": 5, "state": "file", "uid": 0}[root@Monitor ansible]# ansible 192.168.180.6 -m file -a "path=/tmp/test state=absent" #############在远程主机删除文件192.168.180.6 | SUCCESS => { "changed": true, "path": "/tmp/test", "state": "absent"}[root@Monitor ansible]# ansible 192.168.180.6 -m file -a "path=/tmp/fstab state=absent" #############在远程主机删除fstab软连接192.168.180.6 | SUCCESS => { "changed": true, "path": "/tmp/fstab", "state": "absent"} |
6,copy模块。实现复制文件到远程主机,copy模块包含如下选项:
backup:在覆盖之前将原文件备份,备份文件包含时间信息。有两个选项:yes|no
content:用于替代"src",可以直接设定指定文件的值
dest:必选项。要将源文件复制到的远程主机的绝对路径,如果源文件是一个目录,那么该路径也必须是个目录
directory_mode:递归的设定目录的权限,默认为系统默认权限
force:如果目标主机包含该文件,但内容不同,如果设置为yes,则强制覆盖,如果为no,则只有当目标主机的目标位置不存在该文件时,才复制。默认为yes
others:所有的file模块里的选项都可以在这里使用
src:要复制到远程主机的文件在本地的地址,可以是绝对路径,也可以是相对路径。如果路径是一个目录,它将递归复制。在这种情况下,如果路径使用"/"来结尾,则只复制目录里的内容,如果没有使用"/"来结尾,则包含目录在内的整个内容全部复制,类似于rsync。
以下的例子试下拷贝/etc/ansible/script.sh文件到主机组web1所有的主机/tmp下并更新文件属主和权限
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@Monitor ansible]# ansible web1 -m copy -a "src=/etc/ansible/script.sh dest=/tmp/ owner=appuser group=appuser mode=0755" ###复制本地脚本到远程主机server6下并定义用户和组以及权限755Server6 | SUCCESS => { "changed": true, "checksum": "18ca258e92141948010f2e0896cf655cdb945a1d", "dest": "/tmp/script.sh", "gid": 500, "group": "appuser", "md5sum": "d5e15b2da056fdd7b7ba30100035de2e", "mode": "0755", "owner": "appuser", "size": 30, "src": "/root/.ansible/tmp/ansible-tmp-1504517543.07-102988847745614/source", "state": "file", "uid": 500} |
7,service模块。用于远程主机的服务管理。该模块包含如下选项:
arguments:给命令行提供一些选项
enabled:是否开机启动 yes|no
name:必选项,服务名称
pattern:定义一个模式,如果通过status指令来查看服务的状态时,没有响应,就会通过ps指令在进程中根据该模式进行查找,如果匹配到,则认为该服务依然在运行
runlevel:运行级别
sleep:如果执行了restarted,在则stop和start之间沉睡几秒钟
state:对当前服务执行启动,停止、重启、重新加载等操作(started,stopped,restarted,reloaded)
|
1
2
3
4
5
6
7
8
|
####重启远程主机180.6的网卡服务[root@Monitor ansible]# ansible 192.168.180.6 -m service -a "name=network state=restarted args=eth0"192.168.180.6 | SUCCESS => { "changed": true, "name": "network", "state": "started"} |
8,cron模块。用于远程主机crontab配置,管理计划任务包含如下选项:
backup:对远程主机上的原任务计划内容修改之前做备份
cron_file:如果指定该选项,则用该文件替换远程主机上的cron.d目录下的用户的任务计划
day:日(1-31,*,*/2,……)
hour:小时(0-23,*,*/2,……)
minute:分钟(0-59,*,*/2,……)
month:月(1-12,*,*/2,……)
weekday:周(0-7,*,……)
job:要执行的任务,依赖于state=present
name:该任务的描述
special_time:指定什么时候执行,参数:reboot,yearly,annually,monthly,weekly,daily,hourly
state:确认该任务计划是创建还是删除
user:以哪个用户的身份执行
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@Monitor ansible]# ansible 192.168.180.6 -m cron -a 'name="a job for reboot" special_time=reboot job="/some/job.sh"'192.168.180.6 | SUCCESS => { "changed": true, "envs": [], "jobs": [ "a job for reboot" ]}##########客户端-bash-4.1# crontab -l#Ansible: a job for reboot@reboot /some/job.sh |
9,yum模块。Linux平台软件包管理操作 常见的有yum apt 管理方式,其选项有:
config_file:yum的配置文件
disable_gpg_check:关闭gpg_check
disablerepo:不启用某个源
enablerepo:启用某个源
name:要进行操作的软件包的名字,也可以传递一个url或者一个本地的rpm包的路径
state:状态(present,absent,latest)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@Monitor ansible]# ansible 192.168.180.6 -m yum -a "name=curl state=latest"192.168.180.6 | SUCCESS => { "changed": true, "msg": "", "rc": 0, "results": [ "已加载插件:fastestmirror\n设置更新进程\nLoading mirror speeds from cached hostfile\n解决依赖关系\n--> 执行事务检查\n---> Package curl.x86_64 0:7.19.7-52.el6 will be 升级\n---> Package curl.x86_64 0:7.19.7-53.el6_9 will be an update\n--> 处理依赖关系 libcurl = 7.19.7-53.el6_9,它被软件包 curl-7.19.7-53.el6_9.x86_64 需要\n--> 执行事务检查\n---> Package libcurl.x86_64 0:7.19.7-52.el6 will be 升级\n---> Package libcurl.x86_64 0:7.19.7-53.el6_9 will be an update\n--> 完成依赖关系计算\n\n依赖关系解决\n\n================================================================================\n 软件包 架构 版本 仓库 大小\n================================================================================\n正在升级:\n curl x86_64 7.19.7-53.el6_9 updates 197 k\n为依赖而更新:\n libcurl x86_64 7.19.7-53.el6_9 updates 169 k\n\n事务概要\n================================================================================\nUpgrade 2 Package(s)\n\n总下载量:367 k\n下载软件包:\n--------------------------------------------------------------------------------\n总计 3.1 MB/s | 367 kB 00:00 \n运行 rpm_check_debug \n执行事务测试\n事务测试成功\n执行事务\n\r 正在升级 : libcurl-7.19.7-53.el6_9.x86_64 1/4 \n\r 正在升级 : curl-7.19.7-53.el6_9.x86_64 2/4 \n\r 清理 : curl-7.19.7-52.el6.x86_64 3/4 \n\r 清理 : libcurl-7.19.7-52.el6.x86_64 4/4 \n\r Verifying : libcurl-7.19.7-53.el6_9.x86_64 1/4 \n\r Verifying : curl-7.19.7-53.el6_9.x86_64 2/4 \n\r Verifying : curl-7.19.7-52.el6.x86_64 3/4 \n\r Verifying : libcurl-7.19.7-52.el6.x86_64 4/4 \n\n更新完毕:\n curl.x86_64 0:7.19.7-53.el6_9 \n\n作为依赖被升级:\n libcurl.x86_64 0:7.19.7-53.el6_9 \n\n完毕!\n" ]}#######远程客户端的主机180.6yum更新之前-bash-4.1# rpm -qa|grep curlpython-pycurl-7.19.0-9.el6.x86_64libcurl-7.19.7-52.el6.x86_64curl-7.19.7-52.el6.x86_64#######远程客户端的主机180.6yum更新之后-bash-4.1# rpm -qa|grep curlpython-pycurl-7.19.0-9.el6.x86_64libcurl-7.19.7-53.el6_9.x86_64curl-7.19.7-53.el6_9.x86_64 |
10.user模块。实现远程主机系统用户管理。
home:指定用户的家目录,需要与createhome配合使用
groups:指定用户的属组
uid:指定用的uid
password:指定用户的密码
name:指定用户名
createhome:是否创建家目录 yes|no
system:是否为系统用户
remove:当state=absent时,remove=yes则表示连同家目录一起删除,等价于userdel -r
state:是创建还是删除
shell:指定用户的shell环境
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@Monitor ansible]# ansible 192.168.180.6 -m user -a 'name=www1 comment=lqb uid=1001 group=root ' ###新建www1用户192.168.180.6 | SUCCESS => { "changed": true, "comment": "lqb", "createhome": true, "group": 0, "home": "/home/www1", "name": "www1", "shell": "/bin/bash", "state": "present", "system": false, "uid": 1001}[root@Monitor ansible]# ansible 192.168.180.6 -m user -a 'name=www1 state=absent remove=yes' ########删除www1用户192.168.180.6 | SUCCESS => { "changed": true, "force": false, "name": "www1", "remove": true, "state": "absent"} |
11.rsynchronize模块。使用rsync同步文件,其参数如下:
archive: 归档,相当于同时开启recursive(递归)、links、perms、times、owner、group、-D选项都为yes ,默认该项为开启
checksum: 跳过检测sum值,默认关闭
compress:是否开启压缩
copy_links:复制链接文件,默认为no ,注意后面还有一个links参数
delete: 删除不存在的文件,默认no
dest:目录路径
dest_port:默认目录主机上的端口 ,默认是22,走的ssh协议
dirs:传速目录不进行递归,默认为no,即进行目录递归
rsync_opts:rsync参数部分
set_remote_user:主要用于/etc/ansible/hosts中定义或默认使用的用户与rsync使用的用户不同的情况
mode: push或pull 模块,push模的话,一般用于从本机向远程主机上传文件,pull 模式用于从远程主机上取文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#############使用rsynchronize模块首先远程客户端要先按照rsync包才可以使用[root@Monitor ansible]# ansible 192.168.180.6 -a "yum install rsync -y"192.168.180.6 | SUCCESS | rc=0 >>已加载插件:fastestmirror设置安装进程Loading mirror speeds from cached hostfile解决依赖关系--> 执行事务检查---> Package rsync.x86_64 0:3.0.6-12.el6 will be 安装--> 完成依赖关系计算依赖关系解决================================================================================ 软件包 架构 版本 仓库 大小================================================================================正在安装: rsync x86_64 3.0.6-12.el6 base 335 k事务概要================================================================================Install 1 Package(s)总下载量:335 kInstalled size: 682 k下载软件包:运行 rpm_check_debug 执行事务测试事务测试成功执行事务 正在安装 : rsync-3.0.6-12.el6.x86_64 1/1 Verifying : rsync-3.0.6-12.el6.x86_64 1/1 已安装: rsync.x86_64 0:3.0.6-12.el6 完毕!############远程客户端安装好rsync包后就可以在ansible服务端使用rsync进行同步了[root@Monitor ansible]# ansible 192.168.180.6 -m synchronize -a 'src=/etc/ansible/conf/hosts dest=/tmp/ '192.168.180.6 | SUCCESS => { "changed": true, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -i /root/.ssh/id_rsa_web -S none -o StrictHostKeyChecking=no -o Port=22' --out-format='<<CHANGED>>%i %n%L' \"/etc/ansible/conf/hosts\" \"root@192.168.180.6:/tmp/\"", "msg": "<f+++++++++ hosts\n", "rc": 0, "stdout_lines": [ "<f+++++++++ hosts" ]} |
12.mount模块。主要配置挂载点的。主要的参数如下:
dump
fstype:必选项,挂载文件的类型
name:必选项,挂载点
opts:传递给mount命令的参数
src:必选项,要挂载的文件
state:必选项
present:只处理fstab中的配置
absent:删除挂载点
mounted:自动创建挂载点并挂载之
umounted:卸载
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
###############把本地的磁盘挂载到远程主机180.6上[root@Monitor ansible]# ansible 192.168.180.6 -m mount -a 'name=/tmp/app src=/dev/sda2 fstype=ext4 state=mounted opts=rw'192.168.180.6 | SUCCESS => { "changed": true, "dump": "0", "fstab": "/etc/fstab", "fstype": "ext4", "name": "/tmp/app", "opts": "rw", "passno": "0", "src": "/dev/sda2"}#############下面是查看远程主机是否挂载成功[root@Monitor ansible]# ansible 192.168.180.6 -a 'cat /etc/fstab'192.168.180.6 | SUCCESS | rc=0 >>## /etc/fstab# Created by anaconda on Wed Jan 18 14:50:09 2017## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=942820c4-9134-41da-9271-78ad0f8a33b2 / ext4 defaults 1 1UUID=e5d84663-09d2-429f-9f90-43a37b1a84a7 /opt ext4 defaults 1 2UUID=e9098124-206a-4116-a580-91d1d46fe8a9 swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/sda2 /tmp/app ext4 rw 0 0[root@Monitor ansible]# ansible 192.168.180.6 -a 'df -h' 192.168.180.6 | SUCCESS | rc=0 >>Filesystem Size Used Avail Use% Mounted on/dev/sda1 87G 12G 71G 14% /tmpfs 935M 0 935M 0% /dev/shm/dev/sda2 9.9G 1.4G 8.1G 15% /opt/dev/sda2 9.9G 1.4G 8.1G 15% /tmp/app |
13.get_url模块。该模块主要用于从http,ftp ,https等服务器上下载文件类似于wget。主要选项如下:
sha256sum:下载完成后进行sha256 check;
timeout:下载超时时间,默认10s
url:下载的URL
url_password、url_username:主要用于需要用户名密码进行验证的情况
use_proxy:是事使用代理,代理需事先在环境变更中定义
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
##################从网站下载页面到/tmp/下[root@Monitor ansible]# ansible 192.168.180.6 -m get_url -a "url=http://www.guojinbao.com dest=/tmp/guojinbao mode=0440 force=yes" 192.168.180.6 | SUCCESS => { "changed": true, "checksum_dest": null, "checksum_src": "75fa271ea83d05f2817027cf4009f9e9fda7ef88", "dest": "/tmp/guojinbao", "gid": 0, "group": "root", "md5sum": "e9ea1af241cf68289f3286b99af24baa", "mode": "0440", "msg": "OK (unknown bytes)", "owner": "root", "size": 38033, "src": "/tmp/tmp47gp_m", "state": "file", "uid": 0, "url": "http://www.guojinbao.com"}########远程查看下载目录下有没有刚才下载的文件[root@Monitor ansible]# ansible 192.168.180.6 -a 'ls -lh /tmp/'192.168.180.6 | SUCCESS | rc=0 >>总用量 104Kdrwx------ 2 root root 4.0K 9月 5 16:01 ansible_zwKwyhdrwxr-xr-x. 7 appuser appuser 4.0K 1月 19 2017 app-r--r----- 1 root root 38K 9月 5 16:01 guojinbao-rw-r--r-- 1 root root 1.5K 9月 4 14:25 hosts-r--r----- 1 root root 38K 9月 5 15:59 index.htmldrwxr-xr-x. 3 root root 4.0K 9月 5 15:17 install-rwxr-xr-x 1 appuser appuser 30 9月 4 17:32 script.sh-rwxr-xr-x 1 root root 26 9月 4 15:52 test.sh-rw-------. 1 root root 0 1月 18 2017 yum.log |
14.sysctl包管理模块。用于远程主机sysctl的配置。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@Monitor ansible]# ansible-doc -s sysctl ###########查看sysctl的使用说明- name: Manage entries in sysctl.conf. action: sysctl ignoreerrors # Use this option to ignore errors about unknown keys. name= # The dot-separated path (aka `key') specifying the sysctl variable. reload # If `yes', performs a `/sbin/sysctl -p' if the `sysctl_file' is updated. If `no', does not reload `sysctl' even if the `sysctl_file' is updated. state # Whether the entry should be present or absent in the sysctl file. sysctl_file # Specifies the absolute path to `sysctl.conf', if not `/etc/sysctl.c onf'. sysctl_set # Verify token value with the sysctl command and set with -w if necessary value # Desired value of the sysctl key. |
|
1
2
3
4
5
|
[root@Monitor ansible]# ansible 192.168.180.6 -m sysctl -a "name=kernel.panic value=3 sysctl_file=/etc/sysctl.conf"192.168.180.6 | SUCCESS => { "changed": true} |
15.unarchive模块。功能:解压缩,这个模块有两种用法:
1、将ansible主机上的压缩包在本地解压缩后传到远程主机上,这种情况下,copy=yes
2、将远程主机上的某个压缩包解压缩到指定路径下。这种情况下,需要设置copy=no
具体吃的参数如下:
copy:在解压文件之前,是否先将文件复制到远程主机,默认为yes。若为no,则要求目标主机上压缩包必须存在。
creates:指定一个文件名,当该文件存在时,则解压指令不执行
dest:远程主机上的一个路径,即文件解压的路径
grop:解压后的目录或文件的属组
list_files:如果为yes,则会列出压缩包里的文件,默认为no,2.0版本新增的选项
mode:解决后文件的权限
src:如果copy为yes,则需要指定压缩文件的源路径
owner:解压后文件或目录的属主
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
[root@Monitor ansible]# ansible 192.168.180.6 -m unarchive -a "src=/tmp/install/zabbix-3.0.4.tar.gz dest=/tmp/ mode=0755"192.168.180.6 | SUCCESS => { "changed": true, "dest": "/tmp/", "extract_results": { "cmd": [ "/bin/gtar", "--extract", "-C", "/tmp/", "-z", "-f", "/root/.ansible/tmp/ansible-tmp-1504599995.75-84735087578916/source" ], "err": "", "out": "", "rc": 0 }, "gid": 0, "group": "root", "handler": "TgzArchive", "mode": "01777", "owner": "root", "size": 4096, "src": "/root/.ansible/tmp/ansible-tmp-1504599995.75-84735087578916/source", "state": "directory", "uid": 0}########下面是查看路径下的zabbix解压包[root@Monitor ansible]# ansible 192.168.180.6 -a 'ls -alh /tmp'192.168.180.6 | SUCCESS | rc=0 >>总用量 120Kdrwxrwxrwt. 7 root root 4.0K 9月 5 16:28 .dr-xr-xr-x. 24 root root 4.0K 9月 1 09:45 ..drwx------ 2 root root 4.0K 9月 5 16:28 ansible_1zOyd2drwxr-xr-x. 7 appuser appuser 4.0K 1月 19 2017 app-r--r----- 1 root root 38K 9月 5 16:01 guojinbao-rw-r--r-- 1 root root 1.5K 9月 4 14:25 hostsdrwxrwxrwt 2 root root 4.0K 9月 1 09:45 .ICE-unix-r--r----- 1 root root 38K 9月 5 15:59 index.htmldrwxr-xr-x. 3 root root 4.0K 9月 5 15:17 install-rwxr-xr-x 1 appuser appuser 30 9月 4 17:32 script.sh-rwxr-xr-x 1 root root 26 9月 4 15:52 test.sh-rw-------. 1 root root 0 1月 18 2017 yum.logdrwxr-xr-x 13 www 1000 4.0K 7月 22 2016 zabbix-3.0.4 |
总之,以上就是ansible常用的模块,如果还需要其他的模块的话可以查看下官方文档(http://docs.ansible.com/ansible/latest/list_of_all_modules.html)也可以通过命令来进行查看
1,查看所有的模块命令: ansible-doc -l
2,查看具体某个模块用法:ansible-doc -s MODULE_NAME
自动化运维工具Ansible实战(四)常用模块的更多相关文章
- 企业级LINUX自动化运维工具Ansible实战课程下载
什么是Ansible? Ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.chef.func.fabric)的优点,实现了批量系统配置.批量程序部署.批量 ...
- 自动化运维工具-Ansible之3-playbook
自动化运维工具-Ansible之3-playbook 目录 自动化运维工具-Ansible之3-playbook PlayBook初识 YAML语法 PlayBook部署httpd PlayBook实 ...
- 自动化运维工具Ansible详细部署 (转载)
自动化运维工具Ansible详细部署 标签:ansible 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://sofar.blog. ...
- 在CentOS7.6上安装自动化运维工具Ansible以及playbook案例实操
前言 Ansible是一款优秀的自动化IT运维工具,具有远程安装.远程部署应用.远程管理能力,支持Windows.Linux.Unix.macOS和大型机等多种操作系统. 下面就以CentOS 7.6 ...
- 自动化运维工具-Ansible基础
目录 自动化运维工具-Ansible基础 什么是Ansible 同类型软件对比 Ansible的功能及优点 Ansible的架构 Ansible的执行流程 安装Ansible ansible配置文件 ...
- 自动化运维工具-Ansible之4-变量
自动化运维工具-Ansible之4-变量 目录 自动化运维工具-Ansible之4-变量 变量概述 变量的定义和调用 变量优先级测试 变量优先级测试二 变量注册 facts缓存 变量概述 变量提供 ...
- 自动化运维工具-Ansible之2-ad-hoc
自动化运维工具-Ansible之2-ad-hoc 目录 自动化运维工具-Ansible之2-ad-hoc Ansible ad-hoc Ansible命令模块 Ansible软件管理模块 Ansibl ...
- 自动化运维工具-Ansible之1-基础
自动化运维工具-Ansible之1-基础 目录 自动化运维工具-Ansible之1-基础 Ansible 基本概述 定义 特点 架构 工作原理 任务执行模式 命令执行过程 Ansible 安装 Ans ...
- 自动化运维工具Ansible详细部署 - 人生理想在于坚持不懈 - 51CTO技术博客
自动化运维工具Ansible详细部署 - 人生理想在于坚持不懈 - 51CTO技术博客 自动化运维工具Ansible详细部署
随机推荐
- mysql 查询近几天的结果
//近两天的 不包括当天的数据 select * from order_info 今天的数据 select* fromorder_info where date(createtime)=curdate ...
- Python入门-深浅拷贝
首先我们在这里先补充一下基础数据类型的一些知识: 一.循环删除 1.前面我们学了列表,字典和集合的一些操作方法:增删改查,现在我们来看一下这个问题: 有这样一个列表: lst = ['周杰伦','周润 ...
- Sqlite 数据库分页查询(ListView分页显示数据)
下面介绍一下我的这个demo. 流程简述: 我在raw文件夹下面放了名称为city的数据库,里面包含全国2330个城市,以及所属省,拼音简写等信息. 首先 在进入MainActivity的时候,创建数 ...
- Python学习系列----第四章 函数
4.1 函数定义 函数是python中重要的工具.函数用关键字 def 来定义.def 关键字后跟一个函数的标识符名称,然后跟一对圆括号.圆括号之中可以包括一些变量名,该行以冒号结尾.接下来是一块 ...
- 属性只有一个值的这类 html 属性是怎么回事,该如何设置值;比如:checked = “checked” vs checked = true
参考链接:https://stackoverflow.com/questions/10650233/checked-checked-vs-checked-true 问: What is the dif ...
- PHP 多图片上传实例demo
upload.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...
- 微信小程序——组件(二)
在上篇文章组件(一)里已经讲解了如何创建一个项目,现在继续...讲解一个页面布局以及各个组件的使用.在学习过程中,发现小程序支持flex布局,这对于学习过react native的人来说太好了,布局方 ...
- QT网络编程UDP下C/S架构广播通信
QT有封装好的UDP协议的类,QUdpSocket,里面有我们想要的函数接口.感兴趣的话,可以看看. 先搞服务端吧,写一个子类,继承QDialog类,起名为UdpServer类.头文件要引用我们上边说 ...
- SAP S/4HANA生产订单创建时使用的工厂数据是从什么地方带出来的
大家如果使用我github上的这段代码创建S/4HANA的生产订单时,一定会发现,我在代码里并没有硬编码来指定生产订单的ID,然而运行时会发现我在系统里配置的这个2800被自动使用了,这是怎么做到的呢 ...
- Codeforces Round #434 (Div. 2)【A、B、C、D】
Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...