??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模块
相关推荐
橙露7 分钟前
NNG通信框架:现代分布式系统的通信解决方案与应用场景深度分析
运维·网络·tcp/ip·react.js·架构
小徐敲java11 分钟前
(运维)1Panel服务器面板Docker部署
运维·服务器·docker
得赢科技20 分钟前
智能菜谱研发公司推荐 适配中小型餐饮
大数据·运维·人工智能
goxingman32 分钟前
在 Linux 中查看磁盘运行占用(I/O 使用率)
linux·运维·chrome
小天源33 分钟前
XShell一台控制多台操作详情
linux·运维·服务器
杨江1 小时前
Claude Code开发python应用场景要求
运维
星夜落月1 小时前
Certimate证书自动化管理:从零开始的私有化部署指南
运维·自动化·ssl
夜流冰1 小时前
编程参考 - Linux kernel代码查看
linux·运维·服务器
xu_yule1 小时前
网络和Linux网络-14(IO多路转接)poll和epoll编程-服务器
linux·运维·服务器·epoll·poll
timi先生1 小时前
全新的linux如何进行远程xshell操作?
linux·运维·服务器