kwoodson.yedit
// vim: ft=asciidoc
= yedit 仓库
:toc: macro
:toc-title:
toc::[]
== Ansible 角色: Yedit
这个仓库包含一个用于修改 yaml 文件的 ansible 模块。
我没有找到一个好的方法来通过 ansible 编辑 yaml 文件和管理配置。这是我的尝试。
== 安装
你可以通过 Ansible Galaxy 安装:
$ ansible-galaxy install kwoodson.yedit
如果这样做,你还应该添加一个 `requirements.yml`,让其他使用你 Playbook 的用户知道需要安装哪些依赖:
```yaml
---
- src: kwoodson.yedit
然后,你可以在 Play 中引用它,在使用前导入:
roles:
- kwoodson.yedit
- 使用 yedit 的角色
== 示例
有时需要管理 .yml 文件的配置。 [source,yaml]
- hosts: localhost
gather_facts: no
roles:
kwoodson.yedit tasks:
name: 管理 yaml 文件 yedit: src: /tmp/test.yaml key: a.b.c value: d: e: f: 这是一个测试
name: 获取特定值 yedit: src: /tmp/test.yaml state: list key: a.b.c.d.e.f register: yeditout
debug: var=yeditout
== 开发
由于这是一个角色,只需将其复制到任何被 Ansible 识别的角色目录中。详细信息请参见 http://docs.ansible.com/ansible/latest/index.html[Ansible 文档]:
- http://docs.ansible.com/ansible/devel/playbooks_reuse_roles.html#embedding-modules-and-plugins-in-roles[在角色中嵌入模块和插件]
- http://docs.ansible.com/ansible/latest/intro_configuration.html#module-utils[module_utils]
== 文档
完整的文档可以在 https://github.com/kwoodson/ansible-role-yedit/blob/master/library/yedit.py#L15[这里]找到。 ```