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 ...
随机推荐
- JavaScript DOM查询,原生js实现元素子节点的获取
在网页网页开发中,经常会需要获取某个网页元素的子元素,然后对其进行事件绑定.或样式修改等行为.这些操作对于jquery来说很容易,但是对于原生js会稍微麻烦一些,这里将介绍四种方法获取元素的子元素(本 ...
- H3C查看、删除已经保存配置文件--用户图示(console)以上
<H3C>display saved-configuration //显示已经保存的内容 <H3C>reset saved-configuration //删除 ...
- 2018.11.2浪在ACM集训队第三次测试赛
2018.11.2 浪在ACM 集训队第三次测试赛 整理人:孔晓霞 A 珠心算测试 参考博客:[1]李继朋 B 比例简化 参考博客: [1]李继朋 C 螺旋矩阵 参考博客:[1]朱远迪 D 子矩阵 ...
- CF1220
CF1220 A one和zero特的字母分别是'n'和'z' 输出他们的数量即可 #include<cstdio> #include<iostream> #include&l ...
- Kakuro Extension HDU - 3338 (Dinic)
Kakuro puzzle is played on a grid of "black" and "white" cells. Apart from the t ...
- ansible核心模块playbook介绍
ansible的playbook采用yaml语法,它简单地实现了json格式的事件描述.yaml之于json就像markdown之于html一样,极度简化了json的书写.在学习ansible pla ...
- wpf 自定义 ToolTip 模板
示例是在blend中画的,圆角带阴影和倒三角 <Style x:Key="toolTipStyle" TargetType="ToolTip"> & ...
- 举例理解Hibernate的三种状态(转)
转自:https://blog.csdn.net/yiguang_820/article/details/79073152 初学Hibernate,了解到Hibernate有三种状态:transien ...
- seek方法补充
seek 默认模式是从文件的开始移动光标,一共有0.1.2三种模式 f=open('seek.txt','r',encoding='utf-8') print(f.tell()) f.seek(10, ...
- 9. SOFAJRaft源码分析— Follower如何通过Snapshot快速追上Leader日志?
前言 引入快照机制主要是为了解决两个问题: JRaft新节点加入后,如何快速追上最新的数据 Raft 节点出现故障重新启动后如何高效恢复到最新的数据 Snapshot 源码分析 生成 Raft 节点的 ...