??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模块
相关推荐
sunny_3 小时前
⚡️ vite-plugin-oxc:从 Babel 到 Oxc,我为 Vite 写了一个高性能编译插件
前端·webpack·架构
兆子龙8 小时前
模块联邦(Module Federation)详解:从概念到手把手 Demo
前端·架构
Bigger9 小时前
告别版本焦虑:如何为 Hugo 项目定制专属构建环境
前端·架构·go
狗哥哥14 小时前
微前端架构下的平台级公共组件资源体系设计
前端·架构
两万五千个小时14 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
Mintopia15 小时前
思想长期停在事物表面的深层原因:认知机制、环境结构与技术化治理
架构
兆子龙15 小时前
React Compiler 来了:少写 useMemo,照样稳
前端·架构
兆子龙1 天前
用 React + Remotion 做视频:入门与 AI 驱动生成
前端·架构
一枚前端小姐姐1 天前
低代码平台表单设计系统技术分析(实战二)
低代码·架构·前端框架
爱勇宝1 天前
2026年前端生存规划:只会写页面的人,正在被悄悄淘汰
前端·后端·架构