??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模块
相关推荐
周杰伦_Jay8 分钟前
【深度拆解智能体技术底层逻辑】从架构到实现的完整解析
人工智能·机器学习·架构·开源·论文·peai2026
Hello.Reader13 分钟前
Flink Materialized Table 完整部署与运维指南:架构、SQL Gateway、Catalog Store、调度刷新一站式落地
运维·架构·flink
Ancelin安心13 分钟前
关于代理的一些网络知识复盘
linux·运维·网络·计算机网络·web安全·ubuntu·网络安全
程序边界14 分钟前
10年Oracle运维转战国产数据库:迁移路上的“坑”与“光”
运维·数据库·oracle
guslegend15 分钟前
第4节:项目性能优化(完)
架构
chenyuhao202416 分钟前
Linux系统编程:多线程互斥以及死锁问题
linux·运维·服务器·c++·后端
星星泡饭29220 分钟前
从工时消耗到自动化闭环:THERMOMARK E 系列如何定义 2025 工业标识新标准
运维·自动化·菲尼克斯
谢尔登26 分钟前
React的Fiber架构
前端·react.js·架构
默|笙27 分钟前
【Linux】进程(6)虚拟地址空间
linux·运维·服务器
linzihahaha29 分钟前
vmware-ubuntu 虚拟机共享文件及复制拖动配置
linux·运维·ubuntu