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

ansible python module location = ~/python3.x/site-packages/ansible-2.7.8.post0-py3.x.egg/ansible/modules/

File模块

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

  - name: create file

     file: 'path=/tmp/test.txt state=touch mode=0755 owner=user01 group=user01'

Copy模块

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

  - name: copy file

copy: 'remote_src=no src=/tmp/test.txt dest=/tmp/test.txt mode=0644 force=yes'

Stat模块

  获取远程文件状态信息

  - name: check if text.txt exists

stat: 'path=/tmp/text.txt'

register: script_stat   # 将stat结果赋值给 script_stat

Debug模块

  打印语句到Ansible执行输出

  - debug: msg=text.txt exists

     when: script_stat.stat.exists  # 跟Stat模块配合使用

Command/Shell模块

  用来执行Linux目标主机命令,区别为:Shell —— 会调用系统中的/bin/bash,这样就可以使用系统中的环境变量,例如重新向,管道符。

  - name: run a script

   command: 'echo "hello world"'

Template模块

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

  - name: write the nginx config file

     template: src=/tmp/nginx.conf.j2 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常用模块案例操作

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

  2. Ansible Playbooks常用模块

    File模块 在目标主机创建文件或目录,并赋予其系统权限 - name: create a file file:'path=/oot/foo.txt state=touch mode=0755 own ...

  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. synchronized和volatile的使用方法以及区别

    先看看下面的例子: public class ThreadTest { public static void main(String[] args) { final Counter counter = ...

  2. use Properties objects to maintain its configuration Writing Reading System Properties 维护配置 系统变量

    System Properties (The Java™ Tutorials > Essential Classes > The Platform Environment) https:/ ...

  3. the age of the TCP connection TCP Slow Start

    w防止网络过载和拥塞 HTTP The Definitive Guide The performance of TCP data transfer also depends on the age of ...

  4. UEFI,BIOS,MBR,

    UEFI启动是一种新的主板引导项,正被看做是有近20多年历史的BIOS 的继任者.顾名思义,快速启动是可以提高开机后操作系统的启动速度.由于开机过程中UEFI的介入 第一:安全性更强 UEFI启动需要 ...

  5. MapReduce分析流量汇总

    一.MapReduce编程规范 一.MapReduce编程规范 用户编写mr程序主要分为三个部分:Mapper,Reducer,Driver 1.Mapper阶段 (1)用户自定义Mapper类 要继 ...

  6. java组件学习15天

    Linuxdocker redminegitlabnginxmavenkibanakafkaspringspring cloudLucene 搭建基本使用

  7. php用类生成二维码

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq1355541448/article/details/28630289 百度云盘里面已经有了.引用 ...

  8. centos7部署PaaS平台环境(mesos+marathon)

    假如有5台主机可以使用,ip地址如下 规划(2master+3slave) master: 192.168.248.205 ---master1 192.168.248.206 ---master2 ...

  9. 模块讲解----time与date time(时间模块)

    time和datetime 在python中,通常有一下几种方式来表示时间:1.时间戳:2.格式化时间字符串:3.元祖(struct_time):其中元祖(struct_time分为九个元素) UTC ...

  10. mac下python环境pip报错[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) 的解决方法

    1.mac下python环境pip报错: issuserdeMacBook-Pro:~ issuser$ pip install pyinstallerCollecting pyinstaller  ...