??Ansible——ad-hoc

文章目录

一、ad-hoc介绍

二、ad-hoc的使用

1、语法

???

2、ad-hoc常用模块

1)shell模块
bash 复制代码
ansible web_group -m shell -a 'df -h'
bash 复制代码
ansible web_group -m shell -a 'ps -ef | grep nginx'
2)command模块

不能全部识别shell中的特殊符号,如:command无法使用管道符"|"

验证:

bash 复制代码
ansible web_group -m command -a 'ps -ef | grep nginx'
3)script模块

管理机脚本推送到其他机器中

bash 复制代码
ansible web_group -m script -a '/root/test_script_module.sh'
4)file模块

有什么用:

动作:

状态:

5)copy模块
6)yum模块

有什么用:

动作:

  • 1
  • 2
  • 3

状态:

  • 1
  • 2
bash 复制代码
ansible db01 -m yum -a "name=mariadb-server state=present"
7)yum-repository模块

有什么用:

动作:

根据仓库文件的内容的选项:

  • name

    表示仓库的名字

  • description

    对仓库的描述信息

  • baseurl

  • file

  • owner

  • group

  • gpgcheck

    • =yes
    • =no
  • enabled

    • =yes
    • =no

状态:

  • state=present

    创建

  • state=absent

    删除

bash 复制代码
#删除仓库:
ansible web01 -m yum_repository -a 'name=nginx-stable-repos state=absent'
8)service模块

有什么用:

动作:

  • name
    服务名

状态:

  • started
  • stopped
  • restarted
  • reloaded
9)systemd模块
10)user模块
11)group模块
12)mount模块
13)unarchive模块
相关推荐
S+叮当猫1 小时前
第五部分:2---信号的介绍、产生、处理
linux·运维·服务器
东城绝神2 小时前
《Linux运维总结:基于ARM64+X86_64架构CPU使用docker-compose一键离线部署mongodb 7.0.14容器版副本集群》
linux·运维·mongodb·架构
WZF-Sang4 小时前
Linux权限理解【Shell的理解】【linux权限的概念、管理、切换】【粘滞位理解】
linux·运维·服务器·开发语言·学习
小橞5 小时前
Linux搭建简易路由转发
linux·运维·服务器
嵌入式DZC5 小时前
搭建内网文件服务器(FTP),以及实现内网Gitee
运维·服务器
robot_大菜鸟5 小时前
linux-L7-linux 查看json文件
linux·运维
小技与小术7 小时前
lvs-nat模式实验详解
linux·运维·服务器·网络·lvs
FreeBuf_7 小时前
SSHamble:一款针对SSH技术安全的研究与分析工具
运维·安全·ssh
张太行_7 小时前
Linux 调用write()函数后,内核一般多久将数据写入磁盘
linux·运维
Flying_Fish_roe7 小时前
linux-网络管理-防火墙配置
linux·运维·服务器