摘要: 上篇 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 阅读(9031) 评论(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) 编辑