??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模块
相关推荐
七夜zippoe12 分钟前
基于MLC-LLM的轻量级大模型手机端部署实战
android·智能手机·架构·大模型·mlc-llm
子春一18 分钟前
Flutter 架构演进实战:从 MVC 到 Clean Architecture + Modular,打造可维护、可测试、可扩展的企业级应用
flutter·架构·mvc
飞飞传输20 分钟前
新型网闸使用场景:安全隔离与高效交换的双重突破
大数据·运维·安全
头发那是一根不剩了23 分钟前
MySQL 数据目录迁移
运维·服务器·mysql
shizhan_cloud9 小时前
Shell 函数的知识与实践
linux·运维
玖日大大11 小时前
英伟达 AI 芯片:架构演进与智能时代的算力基石
人工智能·架构
2301_8107463112 小时前
CKA冲刺40天笔记 - day20-day21 SSL/TLS详解
运维·笔记·网络协议·kubernetes·ssl
ylmzfun12 小时前
Docker全景解析:从容器化理念到日常实践
docker·eureka·架构
❀͜͡傀儡师12 小时前
docker 部署 komari-monitor监控
运维·docker·容器·komari
物联网软硬件开发-轨物科技12 小时前
【轨物方案】软硬件一体赋能,开启矿山机械远程智慧运维新篇章
运维