Ansible自动化运维工具(2)
(5) ping模块
检测客户端机器的连通性
ansible webserver -m ping
(6) group模块
创建用户的附加组。
ansible webserver -m group -a 'gid=2016 name=test'
验证
ansible webserver -m shell -a 'cat /etc/group | grep test'
注意:
command模块不支持管道符,而shell模块支持。
(7) user模块
该模块用于创建用户。
ansible webserver -m user -a "name=test group=test"
ansible webserver -m user -a "name=test state=absent remove=yes"
(8) shell模块
为ansible的默认模块。可运行所有客户端权限范围内的shell命令。可运行shell script支持管道符。
ansible webserver -m shell -a "/tmp/echo_hello.sh"
(9) script模块
在远端客户机上执行本地Ansible机器中的shell脚本。相当于scp+shell的组合命令。
ansible webserver -m script -a "~/hello.sh"
(10) get_url模块
在远程主机上通过url指示的位置下载,下载的文件抵达远程主机上。
ansible webserver -m get_url -a 'url=http://ftp.linux.com/balabala.rpm dest=/tmp'
(11) yum模块
~ config_file: yum的配置文件
~ disable_gpg_check: 关闭gpg check
~ diablerepo: 不启用某个源
~ enablerepo: 启用某个源
~ name: 要操作的软件包的名字,可以传递一个url或一个本地rpm包的路径
~ state: present(安装)|absent(删除)|latest(安装) 三种状态
ansible 192.168.43.12 -m yum -a 'name=nginx enablerepo=nginx state=present'
ansible 192.168.43.12 -m shell -a 'yum list installed | grep nginx'
获取帮助
ansible-doc yum
(12) cron模块
每天凌晨1点过1分执行对时。
ansible webserver -m cron -a '"name=ntpdate time every day" minute="1" hour="1" job="/sbin/ntpdate ntp.api.bz >> /dev/null"'
获取帮助
ansible-doc cron
(13) service模块
客户端的服务管理。
ansible webserver -m service -a "name=nginx state=started"
ansible webserver -m service -a 'name=mysqld state=started enabled=yes'
6. playbook
导演,指挥,编排器。
模版使用injia2模块处理。使用YAML描述定义。
YAML的变量:{{varname}}
配置文件的语法检查
ansible-playbook ~/httpd.yml --list-hosts --list-tasks
执行yaml配置
ansible-book ~/httpd.yml -f 10
10为并行进程数
Ansible自动化运维工具(2)的更多相关文章
- Ansible自动化运维工具-上
[Ansible特点] 1)Ansible与saltstack均是基于Python语言开发的 2)安装使用简单,基于不同插件和模块实现各种软件,平台,版本的管理以及支持虚拟容器多层级的部署 3)不需要 ...
- Ansible 自动化运维工具
Ansible 自动化运维工具 Ansible是什么? Ansible是一个"配置管理工具"也是一个"自动化运维工具" Ansible 作用: Ansible是 ...
- Ansible自动化运维工具的使用
Ansible自动化运维工具的使用 host lnventory 管理主机 ip root账号密码 ssh端口 core mod ...
- Ansible自动化运维工具及其常用模块
Ansible自动化运维工具及其常用模块 目录 Ansible自动化运维工具及其常用模块 一.Ansible简介 1. Ansible概述 2. Ansible作用 3. Ansible的工作模块 4 ...
- Ansible自动化运维工具使用
概述本文描述自动化运维工具 Ansible 的安装及基础使用方法,包含: Centos 下的安装主机配置Ad-Hoc command(命令行执行)Playbook (任务剧本)Ansible 和 Sa ...
- ansible自动化运维工具使用详解
一. ansible 简介 1. ansible ansible是新出现的 自动化 运维工具 , 基于Python研发 . 糅合了众多老牌运维工具的优点实现了批量操作系统配置.批量程序的部署.批量运行 ...
- Ansible自动化运维工具
ansible软件介绍 python语言是运维人员必会的语言! ansible是一个基于Python开发的自动化运维工具!(saltstack) 其功能实现基于SSH远程连接服务! ans ...
- [Linux]Ansible自动化运维② - 工具与模块
目录 一.Ansible的工具 1.1 Ansible的工作前提 1.2 Ansible的安装文件 1.3 Ansible的配置文件 1.4 Ansible的相关工具 1.4.1 [帮助工具]Ansi ...
- 三石之道之Ansible自动化运维工具部署
centos6默认python版本为2.6 centos7默认python版本为2.7 ansible需要最低python2.7的支持 总结:centos6要部署ansible工具,需要先升级pyth ...
- ansible自动化运维工具的安装与使用
运行环境 centOS6.6 ansible ansible的功能还是比较多的,博主只用它在集群上进行批量部署软件和维护的功能,其他不多做研究,有需要的话这篇文章会慢慢补充. ansible特点 轻量 ...
随机推荐
- Leetcode 13. Roman to Integer(水)
13. Roman to Integer Easy Roman numerals are represented by seven different symbols: I, V, X, L, C, ...
- 【30分钟学完】canvas动画|游戏基础(2):从零开始画画
前言 上篇主要是理论的概述,本篇会多些实践,来讲讲canvas的基础用法,并包含一些基础三角函数的应用,推荐没有canvas基础的朋友阅读,熟悉的朋友可以跳过. 本人能力有限,欢迎牛人共同讨论,批评指 ...
- shouyexinlianjie
http://7xj7xs.com1.z0.glb.clouddn.com/trail_1.mp4
- seq使用
转载! 用于产生从某个数到另外一个数之间的所有整数例一:# seq 1 10结果是1 2 3 4 5 6 7 8 9 10例二:#!/bin/bashfor i in `seq 1 10`;doech ...
- 图书-软件架构:《Design Patterns: Elements of Reusable Object-Oriented Software》(即后述《设计模式》一书)
ylbtech-图书-软件架构:<Design Patterns: Elements of Reusable Object-Oriented Software>(即后述<设计模式&g ...
- 封装好日志的类 logging
import logging from logging import handlers class MyLogger(): def __init__(self,file_name,level='inf ...
- UI自动化之特殊处理二(弹框\下拉框\选项\文件上传)
弹框\下拉框\选项\文件上传也是一些比较特殊的操作 目录 1.弹框 2.下拉框 3.选项 4.文件上传 1.弹框 弹框有三种形式,value为alert.confirm.prompt三种的弹框,第一个 ...
- Nginx配置之rewrite、proxy_pass、upstream、location
如图,这是Nginx的配置文件nginx.conf中的一段配置代码. 在http段中定义了一个名为webservers的upstream模块,主要用于负载均衡. 在server模块中,定义了一个loc ...
- [CCPC-Wannafly & Comet OJ 夏季欢乐赛(2019)]飞行棋
题目链接:https://www.cometoj.com/contest/59/problem/E?problem_id=2714 求期望并且一堆转移基本上就是期望dp了(叉腰 照常的设dp[i]表示 ...
- Python库指南
Python库指南 1.time模块 作用:time模块是一个时间模块,与datetime模块它提供的功能是更加接近于操作系统层面. 应用场景:平时用的比较多的时间戳,等时间方面的操作,在爬虫方面经常 ...