??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模块
相关推荐
用户74883127888526 分钟前
从LangChain 到LangGraph 全解析
架构
中科三方1 小时前
输入域名后无法访问?教你快速区分域名解析问题与服务器问题
运维·服务器
internet Boy1 小时前
桌面运维面试常见问题及标准答案(完整版)
运维
liuluyang5302 小时前
linux kernel CONFIG_KCMP解析
linux·运维·服务器
Koma_zhe2 小时前
【Ansible开源自动化运维工具】别再手动装监控了,Ansible能让上百台机器同时搞定Node Exporter(1)
运维·开源·ansible
heimeiyingwang2 小时前
【架构实战】设计一个日志分析平台(ELK架构)
elk·架构·linq
企业架构师老王3 小时前
货物入库分类混乱与库位规划难题:基于实在Agent的非侵入式仓储架构演进指南
人工智能·ai·架构
生成论实验室3 小时前
《源·觉·知·行·事·物:生成论视域下的统一认知语法》第十七章 科学与人心的重聚
人工智能·算法·架构·知识图谱·创业创新
StackNoOverflow3 小时前
Nginx 入门教程(安装、反向代理、负载均衡、动静分离)
运维·nginx·负载均衡