ansible常用module

ansible-doc
-l List available modules
-s Show playbook snippet for specified module(s) ansible: ansible <host-pattern> [-f forks] [-m module_name] [-a args]
args:
key=value 注意:command模块要执行命令无须为key=value格式,而是直接给出要执行的命令即可; 常用模块:
command
-a 'COMMAND'
#查看web组磁盘空间使用率
ansible web -m command -a 'df -h' user
-a 'name= state={present|absent} system= uid='
#创建系统账户test,uid为444
ansible test -m user -a 'name=test state=present system=yes uid=444'
ansible test -m user -a 'name=test state=absent' group
-a 'name= gid= state= system=' cron
-a 'name= minute= hour= day= month= weekday= job= user= state='
#每3分钟做一次时间同步
ansible test -m cron -a 'name="custom job" minute=*/3 job="/usr/sbin/ntpdate 172.16.254.23"'
ansible test -m cron -a 'name="custom job" state=absent' copy
-a 'dest= src= mode= owner= group='
ansible test -m copy -a 'src=/root/a.sh dest=/tmp/ owner=root group=root mode=0755' file
-a 'path= mode= owner= group= state={directory|link|present|absent} src='
ansible test -m file -a 'path=/tmp/a.sh state=absent' ping
ansible web -m ping yum
-a 'name= state={present|latest|absent}'
ansible test -m yum -a 'name=httpd state=latest'
ansible test -m yum -a 'name=httpd state=absent' service
-a 'name= state={started|stopped|restarted} enabled='
ansible test -m service -a 'name=httpd state=started enabled=yes' shell
-a 'COMMAND'
ansible test -m shell -a 'chkconfig --list httpd' script
-a '/path/to/script'
ansible test -m script -a '/root/a.sh' setup
ansible web -m setup synchronize
-a 'src= dest= mode={pull|push} rsync_opts="auv"'
ansible webg:webappg -m synchronize -a 'src=/app/webapps/app/ dest=/app/webapps/app/ mode=push rsync_opts="-av"'

ansible实践的更多相关文章

  1. Nebula Graph 的 Ansible 实践

    本文首发于 Nebula Graph 公众号 NebulaGraphCommunity,Follow & 看大厂图数据库技术实践 背景 在 Nebula-Graph 的日常测试中,我们会经常在 ...

  2. ansible实践4- 管理配置文件

    生产环境中大多时候是需要管理配置文件的,安装软件包只是在初始化环境的时候用一下.下面我们来写个管理nginx配置文件的playbook   mkdir  -p /etc/ansible/nginx_c ...

  3. ansible实践3-playbook条件判断

    --- - hosts: testhost   user: root   gather_facts: True   tasks:     - name: use when       shell: t ...

  4. ansible实践2-拷贝文件或目录

      ansible testhost -m copy -a "src=/etc/ansible  dest=/tmp/ansibletest owner=root group=root mo ...

  5. ansible实践-1

      不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook 支持sudo 有提供UI(浏览器图形化)www.ans ...

  6. Ansible实践总结

    Ansible playbook 根据条件动态设置变量 首先新建 inventory,主机列表如下: node-01 ansible_host=192.168.64.30 node-02 ansibl ...

  7. Ansible - 简介和应用自动化基础实践

    installAnsible简介和应用自动化基础实践 一.引入: 1.1  如官方定义,Ansible is The simplest way to automate apps and IT infr ...

  8. 《Ansible自动化运维:技术与佳实践》第二章读书笔记

    Ansible 安装与配置 本章主要讲的是 Ansible 安装与基本配置,主要包含以下内容: Ansible 环境准备 安装 Ansible 配置运行环境 Ansible 环境准备 从 GitHub ...

  9. ansible服务部署与使用

    第1章 ssh+key实现基于密钥连接(ansible使用前提) 说明:    ansible其功能实现基于SSH远程连接服务    使用ansible需要首先实现ssh密钥连接 1.1 部署ssh ...

随机推荐

  1. 解决echarts的叠堆折线图数据出现坐标和值对不上的问题

    原文:https://blog.csdn.net/qq_36538012/article/details/88889545 ------------------------------- 说一个小bu ...

  2. LeetCode刷题--有效的括号(简单)

    题目描述 给定一个只包括 ' ( ' , ' )  ',  ' { ' , ' } ' , ' [ ' , ' ] ' 的字符串,判断字符串是否有效.有效字符串需满足: 左括号必须用相同类型的右括号闭 ...

  3. [Visual Studio] 自定义项目模板(.vsix扩展)

    VS自定义项目模板:[2]创建VSIX项目模板扩展 听语音 | 浏览:1237 | 更新:2015-01-02 09:21 | 标签:软件开发 1 2 3 4 5 6 7 分步阅读 一键约师傅 百度师 ...

  4. JUC-12.4-execute和sumbit的区别

    在Executor接口中只定义了execute方法,而submit方法则是在ExecutorService接口中定义的. execute没有返回值,而submit有返回值. 转自: https://w ...

  5. jQuery.each(object, [callback])

    jQuery.each(object, [callback]) 概述 通用遍历方法,可用于遍历对象和数组.大理石平台检定规程 不同于遍历 jQuery 对象的 $().each() 方法,此方法可用于 ...

  6. PHP mysqli_connect_errno() 函数

    返回上一次连接错误的错误代码: <?php $con=mysqli_connect("localhost","wrong_user","my_p ...

  7. xShell终端中文乱码-解决方法

    中文乱码的原因有三种:(1)Linux系统的编码问题(2)xShell终端的编码问题(3)两端的语言编码不一致 linux系统编码 (1) locale:查看系统语言 (2)echo $LANG:查看 ...

  8. C到汇编[1]

    这篇文字解释这个问题:C语言函数调用在汇编语言是怎么实现的?栈模型很好的满足了函数调用的需求,以最简单的函数调用说明. : int add2(int a, int b){return a+b;} 00 ...

  9. Screen 用法简述

    Screen是一款由GNU计划开发的用于命令行终端切换的自由软件.用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换.GNU Screen可以看作是窗口管理器的命令行界面版本.它提 ...

  10. tarjan求强连通分量(模板)

    https://www.luogu.org/problem/P2341 #include<cstdio> #include<cstring> #include<algor ...