File模块

在目标主机创建文件或目录,并赋予其系统权限

- name: create a file
file:'path=/oot/foo.txt state=touch mode=0755
owner=foo group=foo'

Copy模块

实现Ansible服务端到目标主机的文件传送

- name: copy a file
copy:'remote src=no src=roles/testbox/files/foo.sh
dest=/root/foo.sh mode=0644 force=yes'

Stat模块

获取远程文件状态信息

- name: check if foo.sh exists
stat: 'path=/root/foo.sh'
register: script_ stat

Debug模块

打印语句到Ansible执行输出

- debug: msg =foo.sh exists
when: script_ stat.stat.exists

Command/Shell模块

用来执行Linux目标主机命令行

- name: run the script
command:"sh /root/foo.sh" - name: run the script
command:"echo 'test' > /root/test.txt"

Template模块

实现Ansible服务端到目标主机的jinja2模块传送

- name: write the nginx config file
template: src= roles/testbox/templates/nginx.confj2
dest=/etc/nginx/nginx.conf

Packaging模块

调用目标主机系统包管理工具(yum,apt)进行安装

- name: ensure nginx is at the latest version
yum: pkg= nginx state = latest - name: ensure nginx is at the latest version
apt: pkg= nginx state = latest

Service模块

管理目标主机系统服务

- name: start nginx service
service: name = nginx state= started

Ansible Playbooks常用模块的更多相关文章

  1. Ansible Playbooks 常用模块

    官网链接:https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html ansible python module ...

  2. Ansible playbooks常用模块案例操作

    打开git bash 连接ansible服务器,然后进入deploy用户 #ssh root@192.168.96.188 进入python3.6虚拟环境 #su - deploy #source . ...

  3. ansible api常用模块与参数

    ###ansibleAPI 常用模块 用于读取yaml,json格式的文件 from ansible.parsing.dataloader import DataLoader #用于管理变量的类,包括 ...

  4. ansible中常用模块详解

    ansible中常用的模块详解: file模块 ansible内置的可以查看模块用法的命令如下: [root@docker5 ~]# ansible-doc -s file - name: Sets ...

  5. Ansible之常用模块(一)

    ansible之所以功能强大,不是ansible本身,是因为它有众多的模块,前文我们介绍了ansible的基础介绍,系列命令的用法以及选项的说明,通过前文的学习我们知道了ansible是基于pytho ...

  6. ansible API 常用模块

    常用模块 用于读取yaml,json格式的文件 from ansible.parsing.dataloader import DataLoader #用于管理变量的类,包括主机,组,扩展等变量 fro ...

  7. ansible 四常用模块

    常用模块 Ansible默认提供了很多模块来供我们使用.在Linux中,我们可以通过 ansible-doc -l 命令查看到当前Ansible支持哪些模块,通过 ansible-doc -s [模块 ...

  8. ansible 003 常用模块

    常用模块 file 模块 管理被控端文件 回显为绿色则,未变更,符合要求 黄色则改变 红色则报错 因为默认值为file,那么文件不存在,报错 改为touch则创建 将state改为directory变 ...

  9. ansible小结常用模块

    根据官方的分类,将模块按功能分类为:云模块.命令模块.数据库模块.文件模块.资产模块.消息模块.监控模块.网络模块.通知模块.包管理模块.源码控制模块.系统模块.单元模块.web设施模块.window ...

随机推荐

  1. H3C IPv6邻居发现协议

  2. WPF 一个性能比较好的 gif 解析库

    本文介绍 Magick.NET ,这是 ImageMagick 的 .Net 封装,他支持 100 多种格式的图片,而 gif 也是他支持的.本文告诉大家如何使用这个库播放 gif 图 先给大家看一下 ...

  3. 在小程序内点击按钮分享H5网页给好友或者朋友圈

    在小程序内点击按钮分享H5网页给好友或者朋友圈 首先需要建立h5容器文件夹 页面.wxml <navigator url="/pages/report-await/fouryearh5 ...

  4. iview table中的render函数使用

    1.表格列数据内容过多可以用以下两个属性解决: ellipsis:"true', tooltip:true 使每个列的内容如果过多的话变为省略号 2.table中的render函数(实现根据 ...

  5. html根据下拉框选中的值修改背景颜色

    错误的写法 <!doctype html><html><head><meta charset="utf-8"><title&g ...

  6. dotnet core 输出调试信息到 DebugView 软件

    本文告诉大家如何在 dotnet core 输出调试信息到 DebugView 软件 在之前告诉小伙伴,如何在 WPF 输出调试信息到 DebugView 软件,请看文章 WPF 调试 获得追踪输出 ...

  7. Centos7网络连接不上:Network is unreachable 解决方案

    有朋友的centos7装在虚拟机上挂起后在打开不能正常连接网络,我的也出现了这个问题,试着用dhclient重新分配一下地址,无奈系统提示dhclient正在运行,没办法只能试试其它办法,之后研究了一 ...

  8. CSS一行显示,显示不下的用省略号显示

    CSS一行显示,显示不下的用省略号显示 .abc{ white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } 复制上面代码即可 ...

  9. 日志管理-log4j与slf4j的使用

    一.概述 1.log4j: Log4j是Apache的一个开源项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件,甚至是套接口服务器.NT的事件记录器.UNIX Sy ...

  10. The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone错误的解决办法【已解决】

    ---恢复内容开始--- The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time ...