??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模块
相关推荐
BigBigHang37 分钟前
【docker】ollama的docker-compose及一些启动踩坑
运维·docker·容器
Python_Study20251 小时前
企业级数据采集系统选型指南:从技术架构到实战解决方案剖析
架构
CreasyChan1 小时前
VirtualBox 安装 CentOS 7.2
linux·运维·centos
J_liaty1 小时前
Nginx核心功能解析与实战指南
运维·nginx·负载均衡
roman_日积跬步-终至千里1 小时前
【大数据架构:架构思想基础】Google三篇论文开启大数据处理序章:(数据存储)分布式架构、(数据计算)并行计算、(数据管理)分片存储
大数据·分布式·架构
杰克崔1 小时前
glibc社区提问
linux·运维·服务器·车载系统
小股虫2 小时前
数据库外科手术:一份拖垮系统的报表,如何倒逼架构演进
数据库·微服务·设计模式·架构·方法论
乾元2 小时前
网络切片的自动化配置与 SLA 保证——5G / 专网场景中,从“逻辑隔离”到“可验证承诺”的工程实现
运维·开发语言·网络·人工智能·网络协议·重构
Source.Liu2 小时前
【网络】VLAN(虚拟局域网)技术详解
运维·网络
CHrisFC2 小时前
中小型第三方环境检测实验室的数字化破局之选——江苏硕晟LIMS
大数据·运维·人工智能