Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hellojukay/ansible
介绍用 golang 编写 Ansible 插件
https://github.com/hellojukay/ansible
ansible ansible-modules golang
Last synced: 27 days ago
JSON representation
介绍用 golang 编写 Ansible 插件
- Host: GitHub
- URL: https://github.com/hellojukay/ansible
- Owner: hellojukay
- Created: 2017-10-10T01:31:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-30T08:53:01.000Z (about 6 years ago)
- Last Synced: 2024-08-04T06:01:32.909Z (3 months ago)
- Topics: ansible, ansible-modules, golang
- Language: HTML
- Homepage:
- Size: 2.84 MB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ansible
这个项目讲述了Ansible的基本使用方法,和开发自定义模块的方式和例子
# 目录
* [Ansible简介](./doc/introduction.md#desc)
* [Ansible的特点](./doc/introduction.md#tedian)
* [Hello World](./doc/introduction.md#helloworld)
* [安装方式](./doc/introduction.md#anzhuang)
* [Hosts文件](./doc/hosts.md#hosts)
* [编写host文件](./doc/hosts.md#xiehosts)
* [playbook](./doc/playbook.md#playbook)
* [helloworld](./doc/playbook.md#helloworld)
* [变量](./doc/playbook.md#bianliang)
* [条件](./doc/playbook.md#tiaojian)
* [自定义模块](./doc/modeul.md#modeul)
* [参数](./doc/modeul.md#canshu)
* [返回值](./doc/modeul.md#fanhuizhi)
* [使用自定义模块](./doc/modeul.md#shiyon)
* [Ansible配置](./doc/config.md)# demo
这里编写一个名字叫做`fuck`的模块,他的功能是往标准输出里面输出`fuck`.
```golang
package mainimport (
"encoding/json"
)// Response 返回值的消息结构
type Response struct {
Changed bool `json:"changed"`
Fail bool `json:"fail"`
Msg string `json:"msg"`
RC int `json:"rc"`
}func main() {
println("fuck")
var res = Response{
Changed: false,
Fail: false,
Msg: "",
RC: 0,
}
buf, _ := json.Marshal(res)
println(string(buf))
}
```
编译之后放在模块的目录中
```shell
mac-pro:res jukay$ ansible dev -m fuck -u root
39.106.10.228 | SUCCESS => {
"changed": false,
"fail": false,
"msg": "",
"rc": 0
}
mac-pro:res jukay$
```