??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模块
相关推荐
我命由我1234511 分钟前
IDEA - IDEA 快速回到页面首尾、页面快速滑动、快速定位到指定行
java·运维·ide·后端·java-ee·intellij-idea·intellij idea
AI小小怪4 小时前
在Linux服务器上安装CVAT (Docker 28.5.1)
运维·docker·容器·数据标注·cvat
KYGALYX7 小时前
在Linux中备份msyql数据库和表的详细操作
linux·运维·数据库
数字化顾问8 小时前
(125页PPT)IBM流程架构方法论及案例(附下载方式)
架构
lang201509288 小时前
Linux高效备份:tar与gzip完全指南
linux·运维·服务器
●VON8 小时前
深入昇腾NPU:从架构到算子开发的全栈探索
架构·昇腾·昇腾npu·gpt-oss-20b·昇腾训练营
wanhengidc9 小时前
云手机的基本原理
运维·服务器·游戏·智能手机·云计算
篙芷9 小时前
两台服务器 NFS 共享目录实战
运维·服务器
Hard but lovely9 小时前
linux: centos 软件包管理 yum源
linux·运维·centos
2301_8160738310 小时前
Chrony服务器
运维·服务器