??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模块
相关推荐
bigbig_ben18 分钟前
yearning安装docker
运维·docker·容器
智慧光迅AINOPOL3 小时前
园区全光网IP+POL架构怎么设计:组网拓扑与带宽演进
网络协议·tcp/ip·架构
日常筹谋记3 小时前
工业厂房 TPO 防水卷材:技术需求如何传导到配方层面?
运维·网络·html
Linux_cy3 小时前
服务器管理工具哪个好用?我用了七八个
运维·服务器·javascript·python·ssh·面板·gmssh
骑着蜗牛撵大象3273 小时前
语音变分录、规则挡幻觉:拆解开源 AI 记账系统 Smart Ledger 的全栈设计
人工智能·ai·架构·js·数据校验
发量惊人的中年网工6 小时前
抗DDoS服务哪家比较靠谱?选DDoS防护服务重点看哪几点?
运维·ddos
AI办公探索者6 小时前
从“岗位为中心”到“任务为中心”:企业级Agent Hub的架构演进
人工智能·架构
阡陌数智7 小时前
Mistral Large 4 深度拆解:细粒度 MoE 架构与安全 Agent 工程实战
安全·架构
Meta Luo7 小时前
页面改版后自动化用例大量失败,应该怎么维护?
运维·功能测试·测试工具·自动化