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 ...
随机推荐
- Css布局常用 1.盒子内容局中 2. 物理一像素 3.倒三角形 绘制
布局 对象属性 new Person('') 原型链 (创建对象.使用对象中的属性,如果没有那么就去原型找) new Person() Person{ name:'', getname( ...
- Django入门7--博客撰写页面开发
- 2019-9-2-Visual-Studio-自定义项目模板
title author date CreateTime categories Visual Studio 自定义项目模板 lindexi 2019-09-02 12:57:38 +0800 2018 ...
- 2018-8-10-用-sim-卡加密保护资金
title author date CreateTime categories 用 sim 卡加密保护资金 lindexi 2018-08-10 19:16:52 +0800 2018-2-13 17 ...
- H3C 不适当的VLAN间路由方式
- linux 从用户空间的 I/O 存取
刚刚描述的这些函数主要打算被设备驱动使用, 但它们也可从用户空间使用, 至少在 PC- 类 的计算机. GNU C 库在 <sys/io.h> 中定义它们. 下列条件应当应用来对于 inb ...
- PowerShell 通过 WMI 获取系统安装的驱动
本文告诉大家如何通过 WMI 获取用户已经安装的驱动程序 通过下面代码可以获取用户已经安装的驱动程序 Get-WmiObject Win32_SystemDriver | Format-List Ca ...
- <mvc:annotation-driven /><context:annotation-config/><context:component-scan/>
<context:annotation-config/> 隐式地向 Spring容器注册AutowiredAnnotationBeanPostProcessor. RequiredAnno ...
- SQL常见命令
SQLite常见命令:https://www.cnblogs.com/senior-engineer/p/7028972.html
- python 练习题2
# 习题1:# 设定一个用户名和密码,用户输入正确的用户名和密码,# 则显示登录成功,否则提示登录失败,用户最多失败3次,# 否则退出程序.username="test"passw ...