??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模块
相关推荐
安科士andxe6 分钟前
深度解析|安科士100G QSFP28 30km光模块核心技术,破解中长距传输痛点
运维·服务器·网络
01传说7 分钟前
nginx部署教程实战
运维·nginx
Java面试题总结10 分钟前
Linux根分区爆满(占用81%)排查与解决实战
linux·运维·服务器
Bert.Cai10 分钟前
Linux touch命令详解
linux·运维
想要入门的程序猿16 分钟前
VTK与PCL源码编译(Ubuntu 20.04.6)
linux·运维·服务器
EmbeddedCore30 分钟前
轻量级消息防重模块全解析:从原理到高性能优化
linux·运维·服务器·嵌入式硬件
海兰31 分钟前
【实战】HiMarket本地化部署指南
人工智能·ubuntu·架构·银行系统
小程故事多_802 小时前
自然语言智能体控制框架,重塑AI Agent的协作与执行范式
人工智能·架构·aigc·ai编程·harness
2501_933329552 小时前
技术深度拆解:Infoseek舆情系统的全链路架构与核心实现
开发语言·人工智能·分布式·架构
北方的流星2 小时前
华三交换机DHCP服务配置
运维·网络