??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模块
相关推荐
木子欢儿4 分钟前
在 Debian 12 上安装多个版本的 php(7.3、7.4、8.1、8.2)
运维·开发语言·debian·php
GIOTTO情5 分钟前
Infoseek舆情系统全链路架构解析:基于3·15热点的企业舆情管控落地实践
架构
DJ斯特拉6 分钟前
Docker基本使用
运维·docker·容器
云蝠呼叫大模型联络中心6 分钟前
零售行业智能客服与客户数据分析:技术架构与实战案例
大数据·人工智能·架构·数据分析·零售·#智能外呼合规·#云蝠智能
于先生吖9 分钟前
微服务架构下 Java 跑腿系统:分布式部署与性能优化
java·微服务·架构
菩提树下的凡夫10 分钟前
基于C++语言的Onnx CUDA加速部署推理
linux·运维·人工智能
乾元11 分钟前
未来展望: 当 AGI(通用人工智能)出现,网络安全是否会消失?
网络·人工智能·安全·机器学习·网络安全·架构·安全架构
彷徨的蜗牛12 分钟前
定义 AI 驱动的研发新范式:HAFW从需求到部署的端到端智能工作流
人工智能·架构·系统架构
苛子13 分钟前
IDC技术评估8项五星:RestCloud iPaaS定义新一代企业集成架构
架构
zhoupenghui16814 分钟前
跨行转账系统:基于 MVCC 的高并发分布式银行转账架构
架构·mvcc·银行转账