??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模块
相关推荐
木头左6 小时前
【Nginx】内网服务源 IP 白名单实战:动态域名解析放行网段 + 端口接管零改造
运维·nginx·白名单·反向代理
禁默6 小时前
启元 Q1 二次开发实践:Ubuntu 部署与仿真验证,从 PrimeConsole 到 ROS 2 Humble + RViz
linux·运维·ubuntu
skywalk81637 小时前
把 去也网站 从 Ubuntu 搬到 FreeBSD:一次 Service Jail + nginx 的部署实录
linux·运维·nginx·ubuntu·freebsd
翔云1234568 小时前
RocksDB中,客户端每写入一次数据,需要访问几次磁盘
运维·数据库·mysql
国科安芯9 小时前
83 倍:ASC0108S 在推挽和开漏之间,差的不是速度,是回程
单片机·嵌入式硬件·架构·电平转换·抗辐射
爱莉希雅&&&9 小时前
GitLab 完整学习笔记
linux·运维·服务器
小杨爱科普10 小时前
制造业上自动化改造,改造部分的专利到底归谁
运维·经验分享·自动化
QXWZ_IA12 小时前
横跨三网“只进不出”架构如何划分安全边界
安全·架构
方便面不加香菜12 小时前
Docker Container --容器及容器的操作案例详解
运维·docker·容器
ZENERGY-众壹13 小时前
告警风暴怎么压?100MW 电站监控平台告警引擎架构复盘
数据库·架构·iot·电站监控