ansible常用的模块

embedded/2024/10/17 17:34:09/
  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/embedded/126399.html

相关文章

[含文档+PPT+源码等]精品基于asp.net实现的原生Andriod病例管理随访系统[包运行成功+永久免费答疑辅导]

基于ASP.NET实现的原生Android病例管理随访系统背景,可以从以下几个方面进行阐述: 一、技术背景 ASP.NET技术框架 ASP.NET是由微软开发的一种用于构建动态Web应用程序和服务的开源服务器端Web应用框架。它提供了一套丰富的工具和库,支持多种…

应对网站IP劫持的有效策略与技术手段

摘要: IP劫持是一种常见的网络攻击方式,攻击者通过非法手段获取目标网站服务器的控制权,进而改变其网络流量的路由路径,导致用户访问错误的站点。本文将介绍如何识别IP劫持,并提供一系列预防和应对措施,以确…

富士胶片人像汽车照片Lr调色教程,手机滤镜PS+Lightroom预设下载!

调色介绍 富士胶片人像汽车照片的调色旨在营造出独特的复古、文艺氛围。通过 Lightroom 的调色工具,将人像与汽车完美融合在具有富士胶片特色的画面中,展现出别样的美感。 预设信息 调色风格:富士胶片风格预设适合类型:人像&am…

408算法题leetcode--第31天

93. 复原 IP 地址 题目地址:93. 复原 IP 地址 - 力扣(LeetCode) 题解思路:回溯 时间复杂度:O(3^4),IP地址最多包含4个数字,每个数字最多有3种可能的分割方式 空间复杂度:O(n) 代…

elasticsearch 8.2 版本如何设置config/elasticsearch.yml

在Elasticsearch 8.2版本中,`config/elasticsearch.yml`文件是用于配置Elasticsearch的主要配置文件。你可以通过编辑这个文件来设置各种配置选项。以下是一些常见的配置选项及其设置方法: ### 1. 基本配置 #### 集群名称 ```yaml cluster.name: my-cluster ``` #### 节点…

数据结构-4.5.KMP算法(旧版上)-朴素模式匹配算法的优化

朴素模式匹配算法最坏的情况: 一.实例: 第一轮匹配失败,开始下一轮的匹配: 不断的操作,最终匹配成功: 如上述图片所述,朴素模式匹配算法会导致时间开销增加, 优化思路:主…

【CSS Tricks】试试新思路去处理文本超出情况

目录 引言一、常规套路1. 单行文本省略2. 多行文本省略 二、新思路美化一下1. 单行/多行文本隐藏2. 看下效果 三、总结 引言 本篇为css的一个小技巧 文本溢出问题是一个较为常见的场景。UI设计稿为了整体的美观度会将文本内容限制到一定范围内,然而UI设计阶段并不能…

找不到#include “ros/ros.h“

如果在编译过程中找不到 #include "ros/ros.h",通常是因为你的 ROS 环境变量没有正确设置,或者缺少必要的依赖。以下是排查和解决问题的方法: 1. 检查 ROS 安装 确保你已经正确安装了 ROS1,并且安装了必要的开发工具包…