??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模块
相关推荐
架构师沉默6 小时前
别又牛逼了!AI 写 Java 代码真的行吗?
java·后端·架构
桦说编程7 小时前
Harness Engineering — AI 时代的工程最佳实践
人工智能·架构·代码规范
毛骗导演8 小时前
万字解析 OpenClaw 源码架构-安全与权限
前端·架构
非优秀程序员8 小时前
推荐五个OPENclaw 可以应用的场景,让你明白他能干怎么
人工智能·架构·浏览器
ray_liang11 小时前
一小时手搓轻量级可代替 Qdrant 的向量数据库
后端·架构
SparkX开源AI知识库14 小时前
手摸手带你安装OpenClaw并对接飞书
算法·架构
Lee川14 小时前
🌐 深入 Chrome 浏览器:从单线程到多进程架构的进化之路
前端·架构·前端框架
毛骗导演15 小时前
万字解析 OpenClaw 源码架构-架构概览
前端·架构
dossweet16 小时前
我写了一个 Skill,实现了人 + AI + 工程三方受益的增长飞轮
架构·aigc·ai编程
喷火龙8号1 天前
单 Token 认证方案的进阶优化:透明刷新机制
后端·架构