Ansible Playbooks常用模块
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常用模块的更多相关文章
- Ansible Playbooks 常用模块
官网链接:https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html ansible python module ...
- Ansible playbooks常用模块案例操作
打开git bash 连接ansible服务器,然后进入deploy用户 #ssh root@192.168.96.188 进入python3.6虚拟环境 #su - deploy #source . ...
- ansible api常用模块与参数
###ansibleAPI 常用模块 用于读取yaml,json格式的文件 from ansible.parsing.dataloader import DataLoader #用于管理变量的类,包括 ...
- ansible中常用模块详解
ansible中常用的模块详解: file模块 ansible内置的可以查看模块用法的命令如下: [root@docker5 ~]# ansible-doc -s file - name: Sets ...
- Ansible之常用模块(一)
ansible之所以功能强大,不是ansible本身,是因为它有众多的模块,前文我们介绍了ansible的基础介绍,系列命令的用法以及选项的说明,通过前文的学习我们知道了ansible是基于pytho ...
- ansible API 常用模块
常用模块 用于读取yaml,json格式的文件 from ansible.parsing.dataloader import DataLoader #用于管理变量的类,包括主机,组,扩展等变量 fro ...
- ansible 四常用模块
常用模块 Ansible默认提供了很多模块来供我们使用.在Linux中,我们可以通过 ansible-doc -l 命令查看到当前Ansible支持哪些模块,通过 ansible-doc -s [模块 ...
- ansible 003 常用模块
常用模块 file 模块 管理被控端文件 回显为绿色则,未变更,符合要求 黄色则改变 红色则报错 因为默认值为file,那么文件不存在,报错 改为touch则创建 将state改为directory变 ...
- ansible小结常用模块
根据官方的分类,将模块按功能分类为:云模块.命令模块.数据库模块.文件模块.资产模块.消息模块.监控模块.网络模块.通知模块.包管理模块.源码控制模块.系统模块.单元模块.web设施模块.window ...
随机推荐
- java 标准流
标准输入流: System.in 默认表示的是键盘录入 标准输出流: System.out 默认表示的是屏幕输出 Eg: package june6D; import java.io. ...
- 2019-9-2-win10-uwp-列表模板选择器
title author date CreateTime categories win10 uwp 列表模板选择器 lindexi 2019-09-02 12:57:38 +0800 2018-2-1 ...
- H3C 无类域间路由斜线表示法
- 【u105】路径计数2
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 一个N×N的网格,你一开始在(1, 1),即左上角.每次只能移动到下方相邻的格子或者右方相邻的格子,问 ...
- 1134 最长上升子序列 (序列型 DP)
思路: 由于一般的动态规划时间复杂度是O(n^2)(哈哈哈哈 第一次用的就是这个!)用在这里由于n最大为50000 所以会超时 到这里我们可以用一个数组来动态维护这个最长上升的子序列,将你要输入的子序 ...
- computed计算属性(二)
一.说明 在computed中,可以定义一些属性,即计算属性. 计算属性本质是方法,只是在使用这些计算属性的时候,把他们的名称直接当作属性来使用,并不会把计算属性当作方法去调用,不需要加小括号()调用 ...
- Linux 内核PCI去除一个设备
一个 PCI 可用多个不同的方法被从系统中去除. 所有的 card-bus 设备在一个不同的物 理因素上是真正的 PCI 设备, 并且内核 PCI 核心不区分它们. 允许在机器运行时加减 PCI 设备 ...
- Recall(召回率);Precision(准确率);F1-Meature(综合评价指标);true positives;false positives;false negatives..
转自:http://blog.csdn.net/t710smgtwoshima/article/details/8215037 Recall(召回率);Precision(准确率);F1-Meat ...
- 2018-8-14-resharper-自定义代码片
title author date CreateTime categories resharper 自定义代码片 lindexi 2018-08-14 17:34:51 +0800 2018-2-13 ...
- C# struct和class
文字说明 值类型,存储于堆栈,存在于计算机内存逻辑区域中 引用类型,存储在堆中,位于计算机的不同逻辑位置 struct是值类型 推荐较小的数据类型使用,因为结构的大小会影响应用程序的性能 修改实际上是 ...