This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
/
doc.go
168 lines (168 loc) · 5.42 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// This is a Go client for Opscode's Chef.
//
// Obviously many of the unit tests require a functioning Chef installation in
// order to verify the results of API requests. Edit the `TEST_CONFIG.json` file
// with the appropriate endpoints and information, and run `go test -v`.
//
// This project has no external dependencies other than the Go standard library.
//
// Like most every other Golang project, this projects documentation can be found
// on godoc at http://godoc.org/github.com/marpaia/chef-golang
//
// The following is an example of a simple Go tool that displays a small amount
// of information about a few different pieces of a Chef infrastructure:
//
// package main
//
// import (
// "fmt"
// "github.com/marpaia/chef-golang"
// "os"
// )
//
// var findNode = "neo4j.example.org"
// var findCookbook = "neo4j"
// var findRole = "Neo4j"
//
// func main() {
// c, err := chef.Connect()
// if err != nil {
// fmt.Println("Error:", err)
// os.Exit(1)
// }
// c.SSLNoVerify = true
//
// // Print detailed information about a specific node
// node, ok, err := c.GetNode(findNode)
// if err != nil {
// fmt.Println("Error:", err)
// os.Exit(1)
// }
// if !ok {
// fmt.Println("\nCouldn't find that node!")
// } else {
// for i := 0; i < 80; i++ {
// fmt.Print("=")
// }
//
// fmt.Println("\nSystem info:", node.Name, "\n")
// fmt.Println(" [+] IP Address:", node.Info.IPAddress)
// fmt.Println(" [+] MAC Address:", node.Info.MACAddress)
// fmt.Println(" [+] Operating System:", node.Info.Platform)
//
// fmt.Println("\n [+] Filesystem Info")
// for partition, info := range node.Info.Filesystem {
// if info.PercentUsed != "" {
// fmt.Println(" - ", partition, "is", info.PercentUsed, "utilized")
// }
// }
//
// fmt.Println("\n [+] Roles")
// for _, role := range node.Info.Roles {
// fmt.Println(" - ", role)
// }
//
// fmt.Println()
// for i := 0; i < 80; i++ {
// fmt.Print("=")
// }
// }
//
// // Print detailed information about a specific cookbook
// cookbook, ok, err := c.GetCookbook(findCookbook)
// if err != nil {
// fmt.Println("Error:", err)
// os.Exit(1)
// }
// if !ok {
// fmt.Println("\nCouldn't find that cookbook!")
// } else {
// fmt.Println("\n\nCookbook info:", findCookbook)
// for _, version := range cookbook.Versions {
// currentVersion, ok, err := c.GetCookbookVersion(findCookbook, version.Version)
// if err != nil {
// fmt.Println("Error:", err)
// os.Exit(1)
// }
// if ok {
// if len(currentVersion.Files) > 0 {
// fmt.Println("\n [+]", findCookbook, currentVersion.Version, "Cookbook Files")
// for _, cookbookFile := range currentVersion.Files {
// fmt.Println(" - ", cookbookFile.Name)
// }
// }
// }
// }
//
// fmt.Println()
// for i := 0; i < 80; i++ {
// fmt.Print("=")
// }
// }
//
// // Print detailed information about a specific role
// role, ok, err := c.GetRole(findRole)
// if err != nil {
// fmt.Println("Error:", err)
// }
// if !ok {
// fmt.Println("\nCouldn't find that role!")
// } else {
// fmt.Println("\n\nRole information:", role.Name)
// fmt.Println("\n[+] Runlist")
// for _, recipe := range role.RunList {
// fmt.Println(" - ", recipe)
// }
// }
// }
//
// Which will output something like this:
//
// ================================================================================
// System info: neo4j.example.org
//
// [+] IP Address: 10.100.1.2
// [+] MAC Address: AA:BB:CC:DD:EE:FF
// [+] Operating System: centos
//
// [+] Filesystem Info
// - /dev/vda is 46% utilized
// - tmpfs is 1% utilized
//
// [+] Roles
// - Base
// - Neo4j
//
// ================================================================================
//
// Cookbook info: neo4j
//
// [+] neo4j 0.1.6 Cookbook Files
// - neo4j-server.properties
// - neo4j-service
// - neo4j-wrapper.conf
//
// [+] neo4j 0.1.5 Cookbook Files
// - neo4j-service
// - neo4j-wrapper.conf
//
// [+] neo4j 0.1.4 Cookbook Files
// - neo4j-service
//
// [+] neo4j 0.1.3 Cookbook Files
// - neo4j-service
//
// [+] neo4j 0.1.2 Cookbook Files
// - neo4j-service
//
// ================================================================================
//
// Role information: Neo4j
//
// [+] Runlist
// - recipe[yum]
// - recipe[ldap]
// - recipe[system]
// - recipe[neo4j::server]
// - recipe[neo4j::web-ui]
package chef