【自动化运维专题2】ansible的Ad-hoc使用场景及举例

【说明】演示环境相关信息在《【自动化运维专题1】ansible的安装和配置及使用准备》节,本文不再说明。

Ansible提供两种完成任务方式:

【方式一】Ad-Hoc命令集, 即命令Ansible。用于临时命令的场景。

【方式二】:就是Ansible-playbook了, 即命令 ansible­-playbook

方式一更注重于解决一些简单或者平时工作中临时遇到的任务, 相当于Linux系统命令行下的Shell命令。

方式二更适合于解决复杂或需固化下来的任务, 相当于Linux系统的Shell Scripts

Ansible命令的可用的选项:

-v,--verbose:输出更详细的执行过程信息,-vvv可得到执行过程所有信息。
-i,PATH,--inventory(清单)=PATH:指定inventory(清单)信息,默认/etc/ansible/hosts
-f NUM,--forks=NUM:并发线程数,默认5个线程。
--private-key=PRIVATE_KEY_FILE:指定密钥文件。
-m NMAE,--module-name=NAME:指定执行使用的模块。
-M DIRECTORY,--module-path=DIRECTORY:指定模块存放路径,默认/usr/share/ansible,也可以通过ANSIBLE_LIBRARY设定默认路径。
-a ‘ARGUMENTS’,--args=‘ARGUMENTS’:模块参数。
-k,--ask-pass SSH:认证密码
-K,--ask-sudo-pass sudo:用户的密码(--sudo时使用)。
-o,--one-line:标准输出至一行。
-s,--sudo:相当于Linux系统下的sudo命令。
-t DIRECTORY,--tree=DIRECTORY:输出信息至DIRECTORY目录下,结果文件以远程主机命名。
-T SECONDS,--timeout=SECONDS:指定连接远程主机的最大超时,单位是秒。
-B NUM,--background=NUM:后台执行命令,超NUM秒后中止正在执行的任务。
-P NUM,--poll=NUM:定期返回后台任务进度。
-u USERNAME,--user=USERNAME:指定远程主机以USERNAME运行命令。
-U SUDO_USERNAME,--sudo-user=SUDO_USERNAME:使用sudo,相当于LInux下的sudo命令。
-c CONNECTION,--connection=CONNECTION:指定连接方式,可用选项paramiko(SSH)、ssh、local,local方式常用于crontab和kickstarts。
-l  SUBSET,--limit=SUBSET:指定运行主机。
-l ~REGEX,--limit=~REGEX:指定运行主机(正则)。
--list-hosts:列出符合条件的主机列表,不执行任何命令。

所有的命令执行都要依赖于事先写好的模块,默认安装好的ansible里面已经自带了很多模块,如:commandrawshellfilecroncopy等,我们可以通过ansible-doc -l 进行查看:

[root@ansible-control ~]# ansible-doc -l
fortios_router_community_list                                 Configure community lists in Fortinet's FortiOS and FortiGate                                                                                 
azure_rm_devtestlab_info                                      Get Azure DevTest Lab facts                                                                                                                   
ecs_taskdefinition                                            register a task definition in ecs                                                                                                             
avi_alertscriptconfig                                         Module for setup of AlertScriptConfig Avi RESTful Object                                                                                      
tower_receive                                                 Receive assets from Ansible Tower                                                                                                             
netapp_e_iscsi_target                                         NetApp E-Series manage iSCSI target configuration                                                                                             
azure_rm_acs                                                  Manage an Azure Container Service(ACS) instance                                                                                               
fortios_log_syslogd2_filter                                   Filters for remote system server in Fortinet's FortiOS and FortiGate                                                                          
junos_rpc                                                     Runs an arbitrary RPC over NetConf on an Juniper JUNOS device                                                                                 
na_elementsw_vlan                                             NetApp Element Software Manage VLAN                                                                                                           
pn_ospf                                                       CLI command to add/remove ospf protocol to a vRouter                                                                                          
pn_snmp_vacm                                                  CLI command to create/modify/delete snmp-vacm                                                                                                 
cp_mgmt_service_sctp                                          Manages service-sctp objects on Check Point over Web Services API                                                                             
onyx_ospf                                                     Manage OSPF protocol on Mellanox ONYX network devices                                                                                         
icx_command                                                   Run arbitrary commands on remote Ruckus ICX 7000 series switches                                                                              
cs_snapshot_policy                                            Manages volume snapshot policies on Apache CloudStack based clouds                                                                            
nxos_install_os                                               Set boot options like boot, kickstart image and issu                                                                                          
cnos_static_route                                             Manage static IP routes on Lenovo CNOS network devices                                                                                        
win_eventlog                                                  Manage Windows event logs                                                                                                                     
vmware_category                                               Manage VMware categories                                                                                                                      
vmware_host_feature_info                                      Gathers info about an ESXi host's feature capability information                                                                              
avi_cluster                                                   Module for setup of Cluster Avi RESTful Object                                                                                                
na_ontap_user                                                 NetApp ONTAP user configuration and management                                                                                                
aci_l3out                                                     Manage Layer 3 Outside (L3Out) objects (l3ext:Out)                                                                                            
memset_server_info                                            Retrieve server information                                                                                                                   
gcp_compute_subnetwork_info                                   Gather info for GCP Subnetwork                                                                                                                
azure_rm_virtualmachinescalesetextension                      Manage Azure Virtual Machine Scale Set (VMSS) extensions                                                                                      
fortios_report_dataset                                        Report dataset configuration in Fortinet's FortiOS and FortiGate                                                                              
avi_api_session                                               Avi API Module                                                                                                                                
avi_networkprofile                                            Module for setup of NetworkProfile Avi RESTful Object                                                                                         
avi_backup                                                    Module for setup of Backup Avi RESTful Object                                                                                                 
aci_interface_policy_cdp                                      Manage CDP interface policies (cdp:IfPol)                                                                                                     
fortios_firewall_vip                                          Configure virtual IP for IPv4 in Fortinet's FortiOS and FortiGate                                                                             
gcp_compute_backend_service                                   Creates a GCP BackendService                                                                                                                  
iam_policy                                                    Manage IAM policies for users, groups, and roles                                                                                              
fortios_system_fips_cc                                        Configure FIPS-CC mode in Fortinet's FortiOS and FortiGate                                                                                    
fortios_log_null_device_setting                               Settings for null device logging in Fortinet's FortiOS and FortiGate                                                                          
win_inet_proxy                                                Manages proxy settings for WinINet and Internet Explorer                                                                                      
fortios_firewall_auth_portal                                  Configure firewall authentication portals in Fortinet's FortiOS and FortiGate                                                                 
……
[root@ansible-control ~]# 

q退出,这里模块太多。

1.Ad-hoc的执行格式

它相当于ansible的单条命令的执行,一个ad-hoc命令的执行,需要按以下格式进行执行:

ansible 主机或主机组 -m 模块名 -a '模块参数' ansible参数

其中:

  • 主机或主机组:是在/etc/ansible/hosts 里进行指定的部分,动态主机组清单可以使用的是脚本从外部应用里获取。
  • 模块名:可以通过ansible-doc -l查看目前安装的模块,默认不指定时,使用的是command模块,具体可以查看/etc/ansible/ansible.cfg #module_name = command 部分,默认模块可以在该配置文件中进行修改;
  • 模块参数:可以通过 ansible-doc 模块名 查看具体的用法及后面的参数;
  • ansible参数:可以通过ansible命令的帮忙信息里查看到,这里有很多参数可以供选择,如是否需要输入密码、是否sudo等。

这里先举一个简单的例子,然后再进一步学习各个模块。比如,现在检查单个主机或者主机组是否存活,命令如下:

[root@ansible-control /]# ansible 192.168.250.50 -m ping
192.168.250.50 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@ansible-control /]# 

上面是检查一台主机的写法,如果是一组主机,且在/etc/ansible/hosts中定义过,可以这样写:

[root@ansible-control /]# ansible myweb -m ping
192.168.250.51 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
192.168.250.50 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@ansible-control /]# 

其中的含义如下:

Success 表示命令执行成功。

=>{……} 表示详细返回结果。

“changed": false" 表示没有对主机做变更。

“ping": "pong"表示执行了ping 命令返回结果为pong

又比如,列出myweb组所有主机:

[root@ansible-control /]# ansible myweb --list
  hosts (2):
    192.168.250.50
    192.168.250.51
[root@ansible-control /]# 

2.10个常用模块
2.1command模块

也就是在远端主机上执行命令,command模块包含如下选项:

  • creates:一个文件名,当该文件存在,则该命令不执行,反正,则执行。
  • free_form:要执行的linux指令
  • chdir:在执行指令之前,先切换到该指定的目录
  • removes:一个文件名,当该文件存在时,则该选项执行,反之,不执行。

该模块执行时,远端主机需要python环境,如果带-a参数,后面不能跟<,>,|,&等字符。

2.1.1使用场景一

批量查看myweb主机组磁盘容量

[root@ansible-control /]# ansible myweb -a "df -Th"
192.168.250.50 | CHANGED | rc=0 >>
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G   18M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        50G  4.1G   46G    9% /
/dev/mapper/centos-home xfs        42G   37M   42G    1% /home
/dev/vda1               xfs      1014M  225M  790M   23% /boot
tmpfs                   tmpfs     379M   12K  379M    1% /run/user/42
tmpfs                   tmpfs     379M     0  379M    0% /run/user/0
192.168.250.51 | CHANGED | rc=0 >>
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G   90M  1.8G    5% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        50G  4.1G   46G    9% /
/dev/mapper/centos-home xfs        42G   37M   42G    1% /home
/dev/vda1               xfs      1014M  185M  830M   19% /boot
tmpfs                   tmpfs     379M   12K  379M    1% /run/user/42
tmpfs                   tmpfs     379M     0  379M    0% /run/user/0
[root@ansible-control /]# 

2.1.2使用场景二

列出myweb主机组登录后的目录

[root@ansible-control /]# ansible myweb -m command -a pwd
192.168.250.50 | CHANGED | rc=0 >>
/root
192.168.250.51 | CHANGED | rc=0 >>
/root
[root@ansible-control /]#

2.1.3使用场景三

查看myweb主机组日期

[root@ansible-control /]# ansible myweb -m command -a 'date'
192.168.250.50 | CHANGED | rc=0 >>
2022年 08月 11日 星期四 14:34:34 CST
192.168.250.51 | CHANGED | rc=0 >>
2022年 08月 11日 星期四 14:34:34 CST
[root@ansible-control /]# 

2.1.4使用场景四

批量查看myweb主机组内存使用情况

[root@ansible-control /]# ansible myweb -m command -a 'free -h'
192.168.250.50 | CHANGED | rc=0 >>
              total        used        free      shared  buff/cache   available
Mem:           3.7G        462M        2.4G         20M        845M        3.0G
Swap:          7.9G          0B        7.9G
192.168.250.51 | CHANGED | rc=0 >>
              total        used        free      shared  buff/cache   available
Mem:           3.7G        426M        2.8G         92M        546M        3.0G
Swap:          7.9G          0B        7.9G
[root@ansible-control /]# 

2.2shell 模块

该模块在远程节点上执行命令,用法和command一样,不过shell模块执行命令的时候使用的是/bin/sh,所以shell模块可以执行任何命令。

2.2.1使用场景一

批量查看远程主机内存使用情况 :

前面command模块也可以查看,这里用shell模块:

[root@ansible-control /]# ansible myweb -m shell -a "free -h"
192.168.250.50 | CHANGED | rc=0 >>
              total        used        free      shared  buff/cache   available
Mem:           3.7G        463M        2.4G         20M        845M        3.0G
Swap:          7.9G          0B        7.9G
192.168.250.51 | CHANGED | rc=0 >>
              total        used        free      shared  buff/cache   available
Mem:           3.7G        425M        2.8G         92M        547M        3.0G
Swap:          7.9G          0B        7.9G
[root@ansible-control /]# 

2.2.1使用场景二

批量查看远程主机sshd进程:

[root@ansible-control ~]# ansible myweb -m shell -a 'ps -ef | grep sshd'
192.168.250.50 | CHANGED | rc=0 >>
root      1188     1  0 8月02 ?       00:00:00 /usr/sbin/sshd -D
root     31045  1188 21 16:47 ?        00:00:00 sshd: root@pts/0
root     31120 31115  0 16:47 pts/0    00:00:00 /bin/sh -c ps -ef | grep sshd
root     31122 31120  0 16:47 pts/0    00:00:00 grep sshd
192.168.250.51 | CHANGED | rc=0 >>
root      1187     1  0 8月02 ?       00:00:00 /usr/sbin/sshd -D
root     25978  1187 23 16:47 ?        00:00:00 sshd: root@pts/0
root     26061 26048  0 16:47 pts/0    00:00:00 /bin/sh -c ps -ef | grep sshd
root     26063 26061  0 16:47 pts/0    00:00:00 grep sshd
[root@ansible-control ~]# 

2.3raw模块

raw模块功能类似于前面说的commandshell能够完成的操作,raw也都能完成。不同的是,raw模块不需要远程主机上的python环境。ansible要执行自动化操作,需要管理机上装ansible,客户机上也需要安装python,如果客户机上没有安装python模块,那么commandshell模块将无法工作,而raw却可以正常工作,因此,如果有的机器是没有装python,或者说安装的python版本在python2.4以下,就可以使用raw模块来装pythonpython-simplejson等。

如果有些机器装不了python,比如交换机,路由器等,那么,直接用raw模块是最好的选择。

2.3.1使用场景一

批量在远程主机上安装ftp服务 :

[root@ansible-control ~]# ansible myweb -m raw -a "yum -y install vsftpd"
192.168.250.50 | CHANGED | rc=0 >>
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.cn99.com
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
updates/7/x86_64/primary_db                                |  16 MB   00:08     
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-29.el7_9 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package         架构            版本                    源                大小
================================================================================
正在安装:
 vsftpd          x86_64          3.0.2-29.el7_9          updates          173 k

事务概要
================================================================================
安装  1 软件包

总下载量:173 k
安装大小:353 k
Downloading packages:
vsftpd-3.0.2-29.el7_9.x86_64.rpm                           | 173 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : vsftpd-3.0.2-29.el7_9.x86_64                                1/1 
  验证中      : vsftpd-3.0.2-29.el7_9.x86_64                                1/1 

已安装:
  vsftpd.x86_64 0:3.0.2-29.el7_9                                                

完毕!
Shared connection to 192.168.250.50 closed.

192.168.250.51 | CHANGED | rc=0 >>
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.huaweicloud.com
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
updates/7/x86_64/primary_db                                |  16 MB   00:07     
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-29.el7_9 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package         架构            版本                    源                大小
================================================================================
正在安装:
 vsftpd          x86_64          3.0.2-29.el7_9          updates          173 k

事务概要
================================================================================
安装  1 软件包

总下载量:173 k
安装大小:353 k
Downloading packages:
vsftpd-3.0.2-29.el7_9.x86_64.rpm                           | 173 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : vsftpd-3.0.2-29.el7_9.x86_64                                1/1 
  验证中      : vsftpd-3.0.2-29.el7_9.x86_64                                1/1 

已安装:
  vsftpd.x86_64 0:3.0.2-29.el7_9                                                

完毕!
Shared connection to 192.168.250.51 closed.

[root@ansible-control ~]# 

2.3.2使用场景二

批量查看远程主机上是否安装了httpd服务

[root@ansible-control ~]# ansible myweb -m raw -a "rpm -qa | grep httpd"
192.168.250.50 | FAILED | rc=1 >>
Shared connection to 192.168.250.50 closed.
non-zero return code
192.168.250.51 | FAILED | rc=1 >>
Shared connection to 192.168.250.51 closed.
non-zero return code
[root@ansible-control ~]# 

上面出错了,需要配置ssh文件。

2.4script模块

script模块是将管理端的shell脚本拷贝到被管理的远程主机上执行,其原理是先将shell复制到远程主机,再在远程主机上执行,此模块的执行,也不需要远程主机上的python环境。

2.4.1使用场景一

批量在远程主机上安装httpd服务

先在管理主机192.168.250.245/myapp下上创建myinstall.sh脚本文件:

[root@ansible-control myapp]# cat myinstall.sh
#!/bin/bash
yum -y install httpd
systemctl start httpd
[root@ansible-control myapp]# 

然后修改有执行的权限,否则远程主机无法执行:

[root@ansible-control myapp]# chmod 755 myinstall.sh
[root@ansible-control myapp]# ll myinstall.sh 
-rwxr-xr-x. 1 root root 55 8月  11 20:58 myinstall.sh
[root@ansible-control myapp]# 

然后在管理机上执行ansible命令:

[root@ansible-control /]# ansible myweb -m script -a '/myapp/myinstall.sh > /mytmp/install.log'
192.168.250.50 | CHANGED => {
    "changed": true, 
    "rc": 0, 
    "stderr": "Shared connection to 192.168.250.50 closed.\r\n", 
    "stderr_lines": [
        "Shared connection to 192.168.250.50 closed."
    ], 
    "stdout": "", 
    "stdout_lines": []
}
192.168.250.51 | CHANGED => {
    "changed": true, 
    "rc": 0, 
    "stderr": "Shared connection to 192.168.250.51 closed.\r\n", 
    "stderr_lines": [
        "Shared connection to 192.168.250.51 closed."
    ], 
    "stdout": "", 
    "stdout_lines": []
}
[root@ansible-control /]# 

这时修改到任意一个被管理端,比如node02节点上看日志:

[root@rsyncnew02 mytmp]# cat install.log
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.huaweicloud.com
软件包 httpd-2.4.6-97.el7.centos.5.x86_64 已安装并且是最新版本
无须任何处理
[root@rsyncnew02 mytmp]# yum remove httpd
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos.5 将被 删除
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package                                      架构                                          版本                                                           源                                               大小
=======================================================================================
正在删除:
 httpd                                        x86_64                                        2.4.6-97.el7.centos.5                                          @updates                                        9.4 M

事务概要
=======================================================================================
移除  1 软件包

安装大小:9.4 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : httpd-2.4.6-97.el7.centos.5.x86_64                                                                                                                                                           1/1 
  验证中      : httpd-2.4.6-97.el7.centos.5.x86_64                                                                                                                                                           1/1 

删除:
  httpd.x86_64 0:2.4.6-97.el7.centos.5                                                                                                                                                                           

完毕!
您在 /var/spool/mail/root 中有新邮件
[root@rsyncnew02 mytmp]# cat install.log
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.huaweicloud.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos.5 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package      架构          版本                           源              大小
================================================================================
正在安装:
 httpd        x86_64        2.4.6-97.el7.centos.5          updates        2.7 M

事务概要
================================================================================
安装  1 软件包

总下载量:2.7 M
安装大小:9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : httpd-2.4.6-97.el7.centos.5.x86_64                          1/1 
  验证中      : httpd-2.4.6-97.el7.centos.5.x86_64                          1/1 

已安装:
  httpd.x86_64 0:2.4.6-97.el7.centos.5                                          

完毕!
[root@rsyncnew02 mytmp]# 

安装成功,此时查看一下服务状态:

[root@rsyncnew02 mytmp]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2022-08-11 21:11:45 CST; 3min 9s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 31914 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
   CGroup: /system.slice/httpd.service
           ├─31914 /usr/sbin/httpd -DFOREGROUND
           ├─31917 /usr/sbin/httpd -DFOREGROUND
           ├─31918 /usr/sbin/httpd -DFOREGROUND
           ├─31919 /usr/sbin/httpd -DFOREGROUND
           ├─31920 /usr/sbin/httpd -DFOREGROUND
           └─31921 /usr/sbin/httpd -DFOREGROUND

8月 11 21:11:44 rsyncnew02 systemd[1]: Starting The Apache HTTP Server...
8月 11 21:11:45 rsyncnew02 httpd[31914]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::5054:ff:fe91:1077. Set the 'ServerName' directive g...s this message
8月 11 21:11:45 rsyncnew02 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@rsyncnew02 mytmp]# 

服务已正常启动。

2.4.2使用场景二

针对某个文件存在或者不存在来执行脚本:

[root@ansible-control /]# ansible myweb -m script -a 'creates=/etc/passwd chdir=/root mytest.sh'
192.168.250.50 | SKIPPED
192.168.250.51 | SKIPPED
[root@ansible-control /]# 

由于/etc/passwd存在,所以直接跳过。

2.5ping模块

测试主机是否联通:

[root@ansible-control /]# ansible myweb -m ping
192.168.250.50 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
192.168.250.51 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@ansible-control /]# 

今天先写到这里,关于ansible命令的其他模块,请看下节《【自动化运维专题3】ansibleAd-hoc使用场景及举例2》。

 原文地址:https://mp.weixin.qq.com/s/trNOSuaRDRP9gmVheA-9Yg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值