??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模块
相关推荐
nbsaas-boot2 分钟前
AI编程的现实困境与未来路径:从“可用”到“可靠”的跃迁
java·运维·开发语言·架构
文言AI3 分钟前
Pi Agent——OpenClaw的大脑是怎么运转的
架构·openclaw
五度易链-区域产业数字化管理平台3 分钟前
基于可信网络的产业链协同方案:五度易链架构解析
架构
草莓熊Lotso28 分钟前
MySQL 多表连接查询实战:内连接 + 外连接
android·运维·数据库·c++·mysql
zhaoshuzhaoshu32 分钟前
微内核架构与事件驱动架构的区别与联系详细对比
职场和发展·架构
gordon~933 分钟前
docker镜像安装
运维·docker·容器
another heaven1 小时前
【软考 单体式系统与微服务系统】
微服务·云原生·架构
草莓熊Lotso1 小时前
Linux 进程信号深度解析(下):信号的保存、阻塞与捕捉
android·linux·运维·服务器·数据库·c++·性能优化
全栈若城5 小时前
HarmonyOS 6 实战:Component3D 与 SURFACE 渲染模式深度解析
3d·架构·harmonyos6
全栈若城5 小时前
HarmonyOS 6 实战:使用 ArkGraphics3D 加载 GLB 模型与 Scene 初始化全流程
3d·华为·架构·harmonyos·harmonyos6