??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模块
相关推荐
云飞云共享云桌面10 分钟前
SolidWorks—天津智能装备工厂1台高配主机共享给10个研发用
运维·服务器·自动化·汽车·制造
苍狗T27 分钟前
LVS相关知识总结
linux·运维·服务器·lvs
千维百策6661 小时前
云服务性能下降事件分析:高可用架构与可用区疏散实践
架构
EnCi Zheng1 小时前
AI Agent(AI智能体) 记忆管理系统设计 — 从向量库边界到生产级 Memory(记忆) 架构
人工智能·架构
纵有疾風起1 小时前
从OSI到TCP/IP——分层架构的思想根源与模型之争
tcp/ip·计算机网络·架构·osi·408·体系结构·分层
各类产品分享1 小时前
什么是AR智慧运维系统,主要能解决什么问题
运维·ar·ar智慧运维解决方案
byte_conn2 小时前
高压级联储能通信架构:CAN隔离与光纤中继的选型实战
网络·架构·制造·信息与通信
RisunJan2 小时前
Linux命令-skill(发送信号给进程)
linux·运维·服务器
潘正翔2 小时前
k8s基础_kubeadm搭建k8s集群
linux·运维·docker·云原生·容器·kubernetes