ansible实践
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实践的更多相关文章
- Nebula Graph 的 Ansible 实践
本文首发于 Nebula Graph 公众号 NebulaGraphCommunity,Follow & 看大厂图数据库技术实践 背景 在 Nebula-Graph 的日常测试中,我们会经常在 ...
- ansible实践4- 管理配置文件
生产环境中大多时候是需要管理配置文件的,安装软件包只是在初始化环境的时候用一下.下面我们来写个管理nginx配置文件的playbook mkdir -p /etc/ansible/nginx_c ...
- ansible实践3-playbook条件判断
--- - hosts: testhost user: root gather_facts: True tasks: - name: use when shell: t ...
- ansible实践2-拷贝文件或目录
ansible testhost -m copy -a "src=/etc/ansible dest=/tmp/ansibletest owner=root group=root mo ...
- ansible实践-1
不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook 支持sudo 有提供UI(浏览器图形化)www.ans ...
- Ansible实践总结
Ansible playbook 根据条件动态设置变量 首先新建 inventory,主机列表如下: node-01 ansible_host=192.168.64.30 node-02 ansibl ...
- Ansible - 简介和应用自动化基础实践
installAnsible简介和应用自动化基础实践 一.引入: 1.1 如官方定义,Ansible is The simplest way to automate apps and IT infr ...
- 《Ansible自动化运维:技术与佳实践》第二章读书笔记
Ansible 安装与配置 本章主要讲的是 Ansible 安装与基本配置,主要包含以下内容: Ansible 环境准备 安装 Ansible 配置运行环境 Ansible 环境准备 从 GitHub ...
- ansible服务部署与使用
第1章 ssh+key实现基于密钥连接(ansible使用前提) 说明: ansible其功能实现基于SSH远程连接服务 使用ansible需要首先实现ssh密钥连接 1.1 部署ssh ...
随机推荐
- SQL SERVER 2008 数据库隔离级别代码演示
SQL SERVER 2008 数据库隔离级别代码演示 个隔离级别(其实这是SQL 工业标) 种隔离级别,本身没有优劣之分,完全取决于应用的场景. 本质上,他们是在 隔离性(紊乱程度) 和 灵活性 ...
- Android Studio +git+jenkins+gitHub
之前做的jenkins+gitlab的jmeter,,,其实已经记不太清楚了. 最近又在搞Android学习,就试一下AndroidStudio+jenkins自动打包apk看看. step1: An ...
- Lua 学习之基础篇五<Lua OS 库>
lua os库提供了简单的跟操作系统有关的功能 1.os.clock() 返回程序所运行使用的时间 local nowTime = os.clock() print("now time is ...
- Node.js Websocket 区分不同的用户
实现ws://serverIP:port/:param1/:param2 .通过param1,param2来管理不同的ws回话,以便实现群发和指定用户的消息推送 npm install ws --sa ...
- python 传参
python不允许程序员选择采用传值还是传引用.Python参数传递采用的肯定是“传对象引用”的方式.这种方式相当于传值和传引用的一种综合.如果函数收到的是一个可变对象(比如字典或者列表)的引用,就能 ...
- JAVA实现WEBSERVICE 上传下载
因公司新项目决定使用webservice与其它项目做交互,于是开始了webservice之旅. 初入webservice的时候第一个接触的工具叫axis2,网上有着大量的简单案例.功能很强大,代 ...
- [Luogu] 可持久化线段树 1(主席树)
https://www.luogu.org/problemnew/show/P3834 #include<cstdio> #include<iostream> #include ...
- Codeforces Round #521 (Div.3)题解
A过水,不讲 题解 CF1077B [Disturbed People] 这题就是个显而易见的贪心可是我考场上差点没想出来 显然把一户被打扰的人家的右边人家的灯关掉肯定比把左边的灯关掉 从左到右扫一遍 ...
- C语言学习笔记4-数据输入和输出
本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/50752127 作者:jadeshu 邮箱: jades ...
- windows游戏编程X86实模式和保护模式
本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/22309359 作者:jadeshu 邮箱: jades ...