??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模块
相关推荐
fjh19971 小时前
使用caddy签发ip证书
运维·服务器
暴力求解1 小时前
Linux进程(六)命令行参数
linux·运维·服务器
sunny_1 小时前
前端构建产物里的 __esModule 是什么?一次讲清楚它的原理和作用
前端·架构·前端工程化
我怎么又饿了呀2 小时前
Linux 下 的Vim/Vi 操作指南
linux·运维·vim
香芋Yu3 小时前
【大模型面试突击】03_大模型架构演进与对比
面试·职场和发展·架构
dl-kun3 小时前
微服务架构中的SLB(服务负载均衡)问题深度解析与配置指南
微服务·架构·负载均衡·三高
专注前端30年3 小时前
负载均衡实战项目搭建指南:从基础到高可用全流程
运维·数据库·负载均衡
码云数智-大飞4 小时前
负载均衡:让网站“扛得住”千万用户访问的秘密武器
运维·负载均衡
AI云原生与云计算技术学院4 小时前
提示系统负载均衡设计:架构师如何通过负载策略提升提示服务的稳定性
运维·ai·负载均衡
猫头虎5 小时前
web开发常见问题解决方案大全:502/503 Bad Gateway/Connection reset/504 timed out/400 Bad Request/401 Unauthorized
运维·前端·nginx·http·https·gateway·openresty