??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 小时前
【Ruby 】脚本和自动化语言 常用的内容
运维·自动化·ruby
小白不想白a5 小时前
【shell】每日shell练习:安全日志入侵检测/系统配置文件合规检查
运维·服务器
洛克大航海6 小时前
Linux 中新建用户
linux·运维·服务器
dehuisun6 小时前
jenkins流水线部署springboot项目
运维·jenkins
蜜蜜不吃糖7 小时前
解决Vcenter告警datastore存储容量不足问题
linux·运维·服务器
周杰伦_Jay7 小时前
【MCP开发部署流程表格分析】MCP架构解析、开发流程、部署方案、安全性分析
人工智能·深度学习·opencv·机器学习·架构·transformer
宠友信息7 小时前
从架构到体验:友猫社区平台的全栈技术解析与功能体系详解
架构
东城绝神7 小时前
《Linux运维总结:基于ARM64+X86_64架构CPU使用docker-compose一键离线部署redis 7.4.5容器版分片集群》
linux·运维·redis·架构·分片集群
hello_2507 小时前
容灾架构术语:RPO和RTO
架构
骇客野人7 小时前
【软考备考】 架构评估质量属性:性能、可用性、安全性、可修改性、可测试性、易用性等详细介绍
架构