ansible常用的模块

news/2024/10/22 17:19:43/
  1. shell: 执行相关命令,支持管道:
- name: Execute the command in remote shell; stdout goes to the specified file on the remoteansible.builtin.shell: somescript.sh >> somelog.txt
  1. command同shell,但是不支持管道
- name: Run command if /path/to/database does not exist (without 'args')ansible.builtin.command: /usr/bin/make_database.sh db_user db_name creates=/path/to/database
  1. unarchive: 将本地的压缩包,复制到远程机器上,然后解压
- name: Extract foo.tgz into /var/lib/fooansible.builtin.unarchive:src: foo.tgzdest: /var/lib/foo
  1. copy: 将本地的压缩包,复制到远程机器上
- name: Copy file with owner and permissionsansible.builtin.copy:src: /srv/myfiles/foo.confdest: /etc/foo.confowner: foogroup: foomode: '0644'
  1. fetch: 将远程的包拉取到本地
- name: Store file into /tmp/fetched/host.example.com/tmp/somefileansible.builtin.fetch:src: /tmp/somefiledest: /tmp/fetched
  1. template: 将jinjia2格式的模板,渲染到远程机器上
- name: Template a file to /etc/file.confansible.builtin.template:src: /mytemplates/foo.j2dest: /etc/file.confowner: bingroup: wheelmode: '0644'
  1. file: 创建和删除文件或目录
- name: Change file ownership, group and permissionsansible.builtin.file:path: /etc/foo.confowner: foogroup: foomode: '0644'
  1. fail:失败模块,遇到立即停止运行ansible
- name: Example using fail and when togetheransible.builtin.fail:msg: The system may not be provisioned according to the CMDB status.when: cmdb_status != "to-be-staged"
  1. wait_for: 等待端口存活
- name: Wait for port 8000 to become open on the host, don't start checking for 10 secondsansible.builtin.wait_for:port: 8000delay: 10
  1. selinux: 启动或者关闭selinux
- name: Enable SELinuxselinux:policy: targetedstate: enforcing
  1. blockinfile:渲染指定内容到某个文件内
- name: Insert/Update "Match User" configuration block in /etc/ssh/sshd_config prepending and appending a new lineansible.builtin.blockinfile:path: /etc/ssh/sshd_configappend_newline: trueprepend_newline: trueblock: |Match User ansible-agentPasswordAuthentication no
  1. yum: rpm包管理模块
- name: Install the latest version of Apacheansible.builtin.yum:name: httpdstate: latest
  1. user: 创建删除用户
- name: Add the user 'johnd' with a specific uid and a primary group of 'admin'ansible.builtin.user:name: johndcomment: John Doeuid: 1040group: admin

http://www.ppmy.cn/news/1538358.html

相关文章

Postman使用-基础篇

前言 本教程将结合业界广为推崇和使用的RestAPI设计典范Github API,详细介绍Postman接口测试工具的使用方法和实战技巧。 在开始这个教程之前,先聊一下为什么接口测试在现软件行业如此重要? 为什么我们要学习Postman? 现代软件…

Python从入门到高手6.3节-字符串操作方法

目录 6.3.1 字符串常用操作方法 6.3.2 获取字符串长度 6.3.3 字符串的大小写操作 6.3.4 删除字符串中的指定字符 6.3.5 字符串的子串查找 6.3.6 字符串的子串统计 6.3.7 字符串的子串替换 6.3.8 字符串的拆分函数 6.3.9 字符串的前缀与后缀 6.3.10 你一定要成为高手 …

服务器开放ftp端口可能会被攻击吗?

服务器开放FTP(文件传输协议)端口确实可能会增加被攻击的风险。FTP是一种相对较老且不够安全的协议,因为它在传输数据时不加密,这使得数据容易在传输过程中被截获。以下是一些与开放FTP端口相关的主要安全风险: 1. 数据拦截:由于F…

AI金融攻防赛:金融场景凭证篡改检测(DataWhale组队学习)

引言 大家好,我是GISer Liu😁,一名热爱AI技术的GIS开发者。本系列文章是我跟随DataWhale 2024年10月学习赛的AI金融攻防赛学习总结文档。本文主要讲解如何解决 金融场景凭证篡改检测的核心问题,以及解决思路和代码实现过程。希望…

详解安卓和IOS的唤起APP的机制,包括第三方平台的唤起方法比如微信

网页唤起APP是一种常见的跨平台交互方式,它允许用户从网页直接跳转到移动应用程序。 这种技术广泛应用于各种场景,比如让用户在浏览器中点击链接后直接打开某个应用,或者从网页引导用户下载安装应用。实现这一功能主要依赖于URL Scheme、Univ…

通义灵码 Visual Studio 下载安装指南(附安装包)

文章目录 前言一、下载和安装指南方法 1:从插件市场安装方法 2:下载安装包安装方法 3:登录并开启智能编码之旅 二、使用指南总结 前言 通义灵码是基于通义大模型的智能编程辅助工具,它提供了多种强大的功能,旨在助力开…

C# string字符串常用处理方法

在C#中,处理字符串时可以使用许多不同的方法。 string.Concat: 用于连接两个或多个字符串。 string result string.Concat("Hello", " ", "World!"); string.Format: 用于格式化字符串,可以插入变…

Linux 安装 NVM 并配置 npm 加速,开发 node 项目不再愁

由于需要在 linux 机器上完成 node 项目的构建,需要安装 nodejs, 想着不同项目需要使用不同的版本,索性安装一下 nvm 吧,因为之前在 windows 上已经安装过 nvm-windows, 应该很容易上手,我尝试了官网提供的几种方式,最…