??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模块
相关推荐
EverydayJoy^v^4 小时前
RH134学习进程——十二.运行容器(1)
linux·运维·容器
b***25114 小时前
电池组PACK自动化生产线的关键流程与核心优势
运维·自动化
哲伦贼稳妥6 小时前
职场发展-遇到以下情况请直接准备后手吧
运维·经验分享·其他·职场和发展
ujainu6 小时前
Flutter + OpenHarmony 游戏开发进阶:主菜单架构与历史最高分持久化
flutter·游戏·架构·openharmony
Exquisite.6 小时前
企业高性能web服务器(4)
运维·服务器·前端·网络·mysql
北塔软件6 小时前
北塔方案 | 政府行业IT运维解决方案
运维·it运维·解决方案·政务
cg_ssh7 小时前
Docker 下启动 Nacos 3.1.1 单机模式
运维·docker·容器
修己xj7 小时前
使用 Docker 部署 SQL Server 并导入 .mdb 文件的完整指南
运维·docker·容器
郝亚军9 小时前
ubuntu-18.04.6-desktop-amd64安装步骤
linux·运维·ubuntu
Web极客码9 小时前
CentOS 7.x如何快速升级到CentOS 7.9
linux·运维·centos