项目作者: hellojukay

项目描述 :
a demo show you how to create ansible module by golang
高级语言: HTML
项目地址: git://github.com/hellojukay/ansible.git
创建时间: 2017-10-10T01:31:23Z
项目社区:https://github.com/hellojukay/ansible

开源协议:

下载


Ansible

这个项目讲述了Ansible的基本使用方法,和开发自定义模块的方式和例子

目录

demo

这里编写一个名字叫做fuck的模块,他的功能是往标准输出里面输出fuck.

  1. package main
  2. import (
  3. "encoding/json"
  4. )
  5. // Response 返回值的消息结构
  6. type Response struct {
  7. Changed bool `json:"changed"`
  8. Fail bool `json:"fail"`
  9. Msg string `json:"msg"`
  10. RC int `json:"rc"`
  11. }
  12. func main() {
  13. println("fuck")
  14. var res = Response{
  15. Changed: false,
  16. Fail: false,
  17. Msg: "",
  18. RC: 0,
  19. }
  20. buf, _ := json.Marshal(res)
  21. println(string(buf))
  22. }

编译之后放在模块的目录中

  1. mac-pro:res jukay$ ansible dev -m fuck -u root
  2. 39.106.10.228 | SUCCESS => {
  3. "changed": false,
  4. "fail": false,
  5. "msg": "",
  6. "rc": 0
  7. }
  8. mac-pro:res jukay$