??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模块
相关推荐
踩着两条虫3 小时前
如何评价VTJ.PRO?
前端·架构·ai编程
张忠琳4 小时前
【vllm】vLLM v1 KV Offload — 模块超深度逐行分析之一(七)
ai·架构·vllm
桌面运维家4 小时前
IDV云桌面vDisk机房网络管控访问限制部署方案
运维·服务器·网络
ShineWinsu4 小时前
对于Linux:动静态库的制作与原理的解析—下
linux·运维·服务器·进程·链接·虚拟地址空间·
easy_coder5 小时前
Agent:从原理、架构到工程落地(上篇)
架构·云计算
张忠琳6 小时前
【vllm】vLLM v1 Attention — 系统级架构深度分析(五)
ai·架构·vllm
KKKlucifer6 小时前
国内堡垒机如何打通云网运维安全一体化
运维·安全
roman_日积跬步-终至千里6 小时前
【案例题-知识点】分篇一:质量属性与架构评估:非功能需求的场景化表达与架构权衡、评估与度量
架构
wydd99_lll6 小时前
docker特权模式下逃逸
运维·docker·容器
ZhengEnCi7 小时前
01a-编码器解码器架构详解
架构