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. 记前端状态管理库Akita中的一个坑

    记状态管理库Akita中的一个坑 Akita是什么 Akita是一种基于RxJS的状态管理模式,它采用Flux中的多个数据存储和Redux中的不可变更新的思想,以及流数据的概念,来创建可观察的数据存储 ...

  2. P1045 和为给定数

    题目描述 给出若干个整数,询问其中是否有一对数的和等于给定的数. 输入格式 共三行: 第一行是整数 \(n(0 \lt n \le 100000)\) ,表示有 \(n\) 个整数. 第二行是n个整数 ...

  3. 【50.00%】【codeforces 747C】Servers

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. ASP.NET MVC4.0+EF+LINQ+bui+bootstrap+网站+角色权限管理系统(4)

    接下来就是菜单管理了,菜单分为两部分,一部分是菜单管理,另一部分是左边的树形菜单 数据库添加菜单表Menus USE [MVCSystem] GO /****** Object: Table [dbo ...

  5. ASP.NET MVC4.0+EF+LINQ+bui+bootstrap+网站+角色权限管理系统(开篇)

    系统预览: 源码下载:http://www.yealuo.com/Home/Detail?KeyValue=2f926407-f80b-4bff-a729-949a53efed7b 创建项目,新手按步 ...

  6. 原生js重写each方法

    js原生有个for-each方法,但是只能遍历数组不能遍历对象; jq有个$.each倒是可以遍历数组和对象,但是项目中如果不想用jq呢,我们就用原生来写一个吧. [12,23,34].forEach ...

  7. Nodejs之使用express框架搭建WEB应用

      首先创建一个index.js,在里面引入相关的中间件,如果没有这些中间件,则需要在nodejs里进入index.js所在的文件夹安装这些模块,安装命令:npm install express ex ...

  8. neo4j-查询示例

    查找名为"Cloud Atlas"的电影 match(cloudAtlas {title:"Cloud Atlas"}) return cloudAtlas 查 ...

  9. python scrapy爬取前程无忧招聘信息

    使用scrapy框架之前,使用以下命令下载库: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple 1.创建项目文件夹 scr ...

  10. requests + bs4 爬取豌豆荚所有应用的信息

    1.分析豌豆荚的接口的规律 - 获取所有app的接口url 2.往每一个接口发送请求,获取json数据 解析并提取想要的数据 app_data: 1.图标 app_img_url 2.名字 app_n ...