??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模块
相关推荐
小二·2 小时前
云原生安全纵深防御:多云环境下的CSPM、CWPP与零信任架构实战
安全·云原生·架构
mCell6 小时前
【万字长文】从 AI SDK 到 mini-opencode:一次很巧的 Go Agent 架构实践
架构·go·agent
小程故事多_808 小时前
OpenClaw工具引擎架构全解析,AI Agent的“双手”如何落地实操
人工智能·架构·aigc·ai编程·openclaw
AwesomeDevin10 小时前
AI时代,我们的任务不应沉溺于与 AI 聊天,🤔 从“对话式编程”迈向“数字软件工厂”
前端·后端·架构
鸠摩智首席音效师10 小时前
如何使用 docker exec 在容器中运行命令 ?
运维·docker·容器
一蓑烟雨*任平生10 小时前
冯·诺依曼架构与哈佛架构
架构
蜡台11 小时前
SPA(Single Page Application) Web 应用(即单页应用)架构模式 更新
前端·架构·vue·react·spa·spa更新
似水এ᭄往昔11 小时前
【Linux】自动化构建-make/Makefile
linux·运维·服务器·ubuntu
顶点多余11 小时前
Linux“信号“从硬件到软件详解
linux·运维·服务器
勘察加熊人11 小时前
ai飞卢小说自动化处理工作流获得提问素材
运维·自动化