上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: 使用api的时候有时候会遇到一些难以想象到的错误,可以通过以下几种方式来定位。 1、使用 自定义 callback class ResultCallback(CallbackBase): def v2_on_any(self, *args, **kwargs): print args print k 阅读全文
posted @ 2017-06-14 11:57 RunningPower 阅读(817) 评论(0) 推荐(0) 编辑
摘要: 上篇 api 的文章 《ansible-playbook api 2.0 直接运行》 介绍的是直接将 tasks 直接写在 代码中的,本文介绍 api 运行整个项目 [root@10_1_162_39 host_vars]# cat test1.yaml - hosts: 10.1.167.36 g 阅读全文
posted @ 2017-05-05 18:17 RunningPower 阅读(2433) 评论(0) 推荐(0) 编辑
摘要: facts 指的是 ansible_facts 变量,ansible 中使用 setup 模块来获取,包含系统的大部分基础硬件信息, [root@10_1_162_39 host_vars]# ll total 16 -rw-r--r-- 1 root root 44 May 5 14:55 hos 阅读全文
posted @ 2017-05-05 17:09 RunningPower 阅读(9026) 评论(2) 推荐(1) 编辑
摘要: 官方文档见 http://docs.ansible.com/ansible/dev_guide/developing_api.html 拿官方的例子修改如下 import json from collections import namedtuple from ansible.parsing.dat 阅读全文
posted @ 2017-05-05 16:28 RunningPower 阅读(1973) 评论(0) 推荐(0) 编辑
摘要: ansible-playbook 配置 hosts 后可以指定变量,通过-k 可以交互输入密码,也可以将密码写在 hosts 文件中。 入口 yaml 文件中通过 {{ ** }} 获取变量,命令行通过 -i 指定 hosts 文件, -e 传入参数,如果同时传入多个 host 参数可使用逗号分隔, 阅读全文
posted @ 2017-05-05 09:40 RunningPower 阅读(8484) 评论(0) 推荐(0) 编辑
摘要: hosts 配置后可以支持指定 端口,密码等其他变量[root@10_1_162_39 host_vars]# ll total 12 -rw-r--r-- 1 root root 236 May 5 09:11 hosts -rw-r--r-- 1 root root 205 May 4 21:0 阅读全文
posted @ 2017-05-05 09:19 RunningPower 阅读(1103) 评论(0) 推荐(0) 编辑
摘要: windows 7 系统下参照官网安装总是会提示出错,现在整理一下安装的流程 1、安装 python 2.7 ,添加环境变量 在 CMD 命令行下运行 2、安装 pywin32 下载之后双击运行即可 3、安装 pip 新建空白文件,复制脚本,重命名,python 运行即可 4、安装 microsof 阅读全文
posted @ 2017-03-07 15:36 RunningPower 阅读(428) 评论(0) 推荐(0) 编辑
摘要: playbook 相当于多个命令的编排组合然后一起运行,类似写脚本。在学习 playbook 之前需要了解 yaml 格式。 编写playbook的步骤: 定义主机与用户 编写任务列表 执行 playbook 当然 playbook 支持拆分多个文件,并且可以使用多种维度的封装,例如定义变量、任务、 阅读全文
posted @ 2017-03-05 19:04 RunningPower 阅读(1835) 评论(0) 推荐(0) 编辑
摘要: 先使用 ansible-doc 获取帮助文档 [root@localhost ~]# ansible-doc ping > PING (/usr/lib/python2.7/site-packages/ansible-2.3.0-py2.7.egg/ansible/modules/system/pi 阅读全文
posted @ 2017-03-05 18:57 RunningPower 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 本文参考 《Ansible 自动化运维和最佳实践》,这两天刚读这本书,写写总结。主控机环境是 centos 7,被控机均是 centos 6.8 。 确保 python 版本大于 2.6 [root@localhost ~]# python Python 2.7.5 (default, Nov 20 阅读全文
posted @ 2017-03-05 18:52 RunningPower 阅读(793) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页