官网链接: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. plsql连接其他服务器的oracle

    plsql除了连接本地的oracle还需要连接其他服务器上的oracle时 1.下载安装oracleClient:2.在oracleClient安装目录下:例如:D:/instantclient_11 ...

  2. HDU3658—How many words

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3658 题目意思: 题目的意思是在52个英文字母里面选择m个字母组成一个字符串,满足以下两个条件.第一是 ...

  3. Oracle Java Mission Control MBean 服务器 飞行记录器

    Oracle Java Mission ControlMBean 服务器飞行记录器

  4. appium+python自动化测试真机测试时报错“info: [debug] Error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]”

    刚开始启动服务时,弹出授权提示,以为是手机app权限问题,后来debug后,发现了一个警告日志:UiAutomator did not shut down fast enough, calling i ...

  5. 多进程使用matplotlib.pyplot绘heatmap(多线程不可以)

    数据格式如下: 8_15/l_eye/2732.png -20.5773 -5.17769 -3.34583 21.5859 9_13_1/l_eye/1211.png -10.1145 34.992 ...

  6. MySQL与Btree

    Btree,B+tree,B*tree 前言: 由于在查找中用二分法在查找一些边缘数据时就会产生数据查找不公平,二叉树也存在类似问题:所以就有了B-tree. B+树索引是B+树在数据库中的一种实现, ...

  7. 深入了解跟踪(trace)

    深入了解跟踪(trace) 转自:https://www.cnblogs.com/zhijianliutang/p/4113911.html 前言 一提到跟踪俩字,很多人想到警匪片中的场景,同样在我们 ...

  8. OCR技术浅探 : 文字定位和文本切割(2)

    文字定位 经过前面的特征提取,我们已经较好地提取了图像的文本特征,下面进行文字定位. 主要过程分两步: 1.邻近搜索,目的是圈出单行文字: 2.文本切割,目的是将单行文本切割为单字. 邻近搜索 我们可 ...

  9. PHP代码编写的优化

    // $b 会新创建一个内存空间 $a = array('a'=>'aa','b'=>'bb'); $b = $a; $a['c'] = 'cc'; // $b 会引用 $a 的内存空间 ...

  10. java 多线程 day16 CountDownLatch 倒计时计数器

    import java.util.concurrent.CountDownLatch;import java.util.concurrent.CyclicBarrier;import java.uti ...