train-f5 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +27 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +238 -0
- data/README.md +115 -0
- data/Rakefile +11 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/train-f5/connection.rb +62 -0
- data/lib/train-f5/error.rb +10 -0
- data/lib/train-f5/transport.rb +22 -0
- data/lib/train-f5/version.rb +7 -0
- data/lib/train-f5.rb +8 -0
- data/train-f5.gemspec +37 -0
- metadata +102 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a19a3cb9829fa7a53cc0df4f22edd11d17ae305df6284773e1cef04db3ec72ee
|
|
4
|
+
data.tar.gz: ad8d5a49a3b88ed53e8d594404368837242139c7eaf6535ceb98c4a27d5bf527
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 97bed029e2315578316f57c50a68d666f52c4f47691057bfa89afe7124733b8d310de080bb39b67d3dee803bf78fa695972b94eaa2150b3ac13b120f6150648e
|
|
7
|
+
data.tar.gz: d0b32b7029381ef6efa085c857616e2ba114f1630bfd44077d63b66b663150d24439cffcb44b512b435889e912f34621221a24e6adf9e73ab14bc702888970f6
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.6
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Style/FetchEnvVar:
|
|
7
|
+
Enabled: false
|
|
8
|
+
|
|
9
|
+
Style/StringLiterals:
|
|
10
|
+
Enabled: true
|
|
11
|
+
EnforcedStyle: double_quotes
|
|
12
|
+
|
|
13
|
+
Style/StringLiteralsInInterpolation:
|
|
14
|
+
Enabled: true
|
|
15
|
+
EnforcedStyle: double_quotes
|
|
16
|
+
|
|
17
|
+
Layout/LineLength:
|
|
18
|
+
Max: 120
|
|
19
|
+
|
|
20
|
+
Naming/FileName:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
Metrics/MethodLength:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
Gemspec/RequireMFA:
|
|
27
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
train-f5 (0.1.0)
|
|
5
|
+
faraday
|
|
6
|
+
faraday_middleware
|
|
7
|
+
train
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
activesupport (7.0.3.1)
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
+
i18n (>= 1.6, < 2)
|
|
15
|
+
minitest (>= 5.1)
|
|
16
|
+
tzinfo (~> 2.0)
|
|
17
|
+
addressable (2.8.1)
|
|
18
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
19
|
+
ast (2.4.2)
|
|
20
|
+
azure_graph_rbac (0.17.2)
|
|
21
|
+
ms_rest_azure (~> 0.12.0)
|
|
22
|
+
azure_mgmt_key_vault (0.17.7)
|
|
23
|
+
ms_rest_azure (~> 0.12.0)
|
|
24
|
+
azure_mgmt_resources (0.18.2)
|
|
25
|
+
ms_rest_azure (~> 0.12.0)
|
|
26
|
+
azure_mgmt_security (0.19.0)
|
|
27
|
+
ms_rest_azure (~> 0.12.0)
|
|
28
|
+
azure_mgmt_storage (0.23.0)
|
|
29
|
+
ms_rest_azure (~> 0.12.0)
|
|
30
|
+
builder (3.2.4)
|
|
31
|
+
chef-utils (17.10.0)
|
|
32
|
+
concurrent-ruby
|
|
33
|
+
concurrent-ruby (1.1.10)
|
|
34
|
+
declarative (0.0.20)
|
|
35
|
+
diff-lcs (1.5.0)
|
|
36
|
+
docker-api (2.2.0)
|
|
37
|
+
excon (>= 0.47.0)
|
|
38
|
+
multi_json
|
|
39
|
+
domain_name (0.5.20190701)
|
|
40
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
41
|
+
erubi (1.11.0)
|
|
42
|
+
excon (0.92.4)
|
|
43
|
+
faraday (1.10.2)
|
|
44
|
+
faraday-em_http (~> 1.0)
|
|
45
|
+
faraday-em_synchrony (~> 1.0)
|
|
46
|
+
faraday-excon (~> 1.1)
|
|
47
|
+
faraday-httpclient (~> 1.0)
|
|
48
|
+
faraday-multipart (~> 1.0)
|
|
49
|
+
faraday-net_http (~> 1.0)
|
|
50
|
+
faraday-net_http_persistent (~> 1.0)
|
|
51
|
+
faraday-patron (~> 1.0)
|
|
52
|
+
faraday-rack (~> 1.0)
|
|
53
|
+
faraday-retry (~> 1.0)
|
|
54
|
+
ruby2_keywords (>= 0.0.4)
|
|
55
|
+
faraday-cookie_jar (0.0.7)
|
|
56
|
+
faraday (>= 0.8.0)
|
|
57
|
+
http-cookie (~> 1.0.0)
|
|
58
|
+
faraday-em_http (1.0.0)
|
|
59
|
+
faraday-em_synchrony (1.0.0)
|
|
60
|
+
faraday-excon (1.1.0)
|
|
61
|
+
faraday-httpclient (1.0.1)
|
|
62
|
+
faraday-multipart (1.0.4)
|
|
63
|
+
multipart-post (~> 2)
|
|
64
|
+
faraday-net_http (1.0.1)
|
|
65
|
+
faraday-net_http_persistent (1.2.0)
|
|
66
|
+
faraday-patron (1.0.0)
|
|
67
|
+
faraday-rack (1.0.0)
|
|
68
|
+
faraday-retry (1.0.3)
|
|
69
|
+
faraday_middleware (1.2.0)
|
|
70
|
+
faraday (~> 1.0)
|
|
71
|
+
ffi (1.15.5)
|
|
72
|
+
google-api-client (0.52.0)
|
|
73
|
+
addressable (~> 2.5, >= 2.5.1)
|
|
74
|
+
googleauth (~> 0.9)
|
|
75
|
+
httpclient (>= 2.8.1, < 3.0)
|
|
76
|
+
mini_mime (~> 1.0)
|
|
77
|
+
representable (~> 3.0)
|
|
78
|
+
retriable (>= 2.0, < 4.0)
|
|
79
|
+
rexml
|
|
80
|
+
signet (~> 0.12)
|
|
81
|
+
googleauth (0.14.0)
|
|
82
|
+
faraday (>= 0.17.3, < 2.0)
|
|
83
|
+
jwt (>= 1.4, < 3.0)
|
|
84
|
+
memoist (~> 0.16)
|
|
85
|
+
multi_json (~> 1.11)
|
|
86
|
+
os (>= 0.9, < 2.0)
|
|
87
|
+
signet (~> 0.14)
|
|
88
|
+
gssapi (1.3.1)
|
|
89
|
+
ffi (>= 1.0.1)
|
|
90
|
+
gyoku (1.4.0)
|
|
91
|
+
builder (>= 2.1.2)
|
|
92
|
+
rexml (~> 3.0)
|
|
93
|
+
http-cookie (1.0.5)
|
|
94
|
+
domain_name (~> 0.5)
|
|
95
|
+
httpclient (2.8.3)
|
|
96
|
+
i18n (1.12.0)
|
|
97
|
+
concurrent-ruby (~> 1.0)
|
|
98
|
+
inifile (3.0.0)
|
|
99
|
+
json (2.6.2)
|
|
100
|
+
jwt (2.5.0)
|
|
101
|
+
little-plugger (1.1.4)
|
|
102
|
+
logging (2.3.1)
|
|
103
|
+
little-plugger (~> 1.1)
|
|
104
|
+
multi_json (~> 1.14)
|
|
105
|
+
memoist (0.16.2)
|
|
106
|
+
mini_mime (1.1.2)
|
|
107
|
+
minitest (5.16.3)
|
|
108
|
+
mixlib-shellout (3.2.7)
|
|
109
|
+
chef-utils
|
|
110
|
+
ms_rest (0.7.6)
|
|
111
|
+
concurrent-ruby (~> 1.0)
|
|
112
|
+
faraday (>= 0.9, < 2.0.0)
|
|
113
|
+
timeliness (~> 0.3.10)
|
|
114
|
+
ms_rest_azure (0.12.0)
|
|
115
|
+
concurrent-ruby (~> 1.0)
|
|
116
|
+
faraday (>= 0.9, < 2.0.0)
|
|
117
|
+
faraday-cookie_jar (~> 0.0.6)
|
|
118
|
+
ms_rest (~> 0.7.6)
|
|
119
|
+
multi_json (1.15.0)
|
|
120
|
+
multipart-post (2.2.3)
|
|
121
|
+
net-scp (3.0.0)
|
|
122
|
+
net-ssh (>= 2.6.5, < 7.0.0)
|
|
123
|
+
net-ssh (6.1.0)
|
|
124
|
+
nori (2.6.0)
|
|
125
|
+
os (1.1.4)
|
|
126
|
+
parallel (1.22.1)
|
|
127
|
+
parser (3.1.2.1)
|
|
128
|
+
ast (~> 2.4.1)
|
|
129
|
+
public_suffix (5.0.0)
|
|
130
|
+
rainbow (3.1.1)
|
|
131
|
+
rake (13.0.6)
|
|
132
|
+
regexp_parser (2.5.0)
|
|
133
|
+
representable (3.2.0)
|
|
134
|
+
declarative (< 0.1.0)
|
|
135
|
+
trailblazer-option (>= 0.1.1, < 0.2.0)
|
|
136
|
+
uber (< 0.2.0)
|
|
137
|
+
retriable (3.1.2)
|
|
138
|
+
rexml (3.2.5)
|
|
139
|
+
rspec (3.11.0)
|
|
140
|
+
rspec-core (~> 3.11.0)
|
|
141
|
+
rspec-expectations (~> 3.11.0)
|
|
142
|
+
rspec-mocks (~> 3.11.0)
|
|
143
|
+
rspec-core (3.11.0)
|
|
144
|
+
rspec-support (~> 3.11.0)
|
|
145
|
+
rspec-expectations (3.11.0)
|
|
146
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
147
|
+
rspec-support (~> 3.11.0)
|
|
148
|
+
rspec-mocks (3.11.1)
|
|
149
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
150
|
+
rspec-support (~> 3.11.0)
|
|
151
|
+
rspec-support (3.11.0)
|
|
152
|
+
rubocop (1.36.0)
|
|
153
|
+
json (~> 2.3)
|
|
154
|
+
parallel (~> 1.10)
|
|
155
|
+
parser (>= 3.1.2.1)
|
|
156
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
157
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
158
|
+
rexml (>= 3.2.5, < 4.0)
|
|
159
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
|
160
|
+
ruby-progressbar (~> 1.7)
|
|
161
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
162
|
+
rubocop-ast (1.21.0)
|
|
163
|
+
parser (>= 3.1.1.0)
|
|
164
|
+
ruby-progressbar (1.11.0)
|
|
165
|
+
ruby2_keywords (0.0.5)
|
|
166
|
+
rubyntlm (0.6.3)
|
|
167
|
+
rubyzip (2.3.2)
|
|
168
|
+
signet (0.17.0)
|
|
169
|
+
addressable (~> 2.8)
|
|
170
|
+
faraday (>= 0.17.5, < 3.a)
|
|
171
|
+
jwt (>= 1.5, < 3.0)
|
|
172
|
+
multi_json (~> 1.10)
|
|
173
|
+
timeliness (0.3.10)
|
|
174
|
+
trailblazer-option (0.1.2)
|
|
175
|
+
train (3.10.1)
|
|
176
|
+
activesupport (>= 6.0.3.1)
|
|
177
|
+
azure_graph_rbac (~> 0.16)
|
|
178
|
+
azure_mgmt_key_vault (~> 0.17)
|
|
179
|
+
azure_mgmt_resources (~> 0.15)
|
|
180
|
+
azure_mgmt_security (~> 0.18)
|
|
181
|
+
azure_mgmt_storage (~> 0.18)
|
|
182
|
+
docker-api (>= 1.26, < 3.0)
|
|
183
|
+
google-api-client (>= 0.23.9, <= 0.52.0)
|
|
184
|
+
googleauth (>= 0.6.6, <= 0.14.0)
|
|
185
|
+
inifile (~> 3.0)
|
|
186
|
+
train-core (= 3.10.1)
|
|
187
|
+
train-winrm (~> 0.2)
|
|
188
|
+
train-core (3.10.1)
|
|
189
|
+
addressable (~> 2.5)
|
|
190
|
+
ffi (!= 1.13.0)
|
|
191
|
+
json (>= 1.8, < 3.0)
|
|
192
|
+
mixlib-shellout (>= 2.0, < 4.0)
|
|
193
|
+
net-scp (>= 1.2, < 4.0)
|
|
194
|
+
net-ssh (>= 2.9, < 7.0)
|
|
195
|
+
train-winrm (0.2.13)
|
|
196
|
+
winrm (>= 2.3.6, < 3.0)
|
|
197
|
+
winrm-elevated (~> 1.2.2)
|
|
198
|
+
winrm-fs (~> 1.0)
|
|
199
|
+
tzinfo (2.0.5)
|
|
200
|
+
concurrent-ruby (~> 1.0)
|
|
201
|
+
uber (0.1.0)
|
|
202
|
+
unf (0.1.4)
|
|
203
|
+
unf_ext
|
|
204
|
+
unf_ext (0.0.7.6)
|
|
205
|
+
unicode-display_width (2.2.0)
|
|
206
|
+
winrm (2.3.6)
|
|
207
|
+
builder (>= 2.1.2)
|
|
208
|
+
erubi (~> 1.8)
|
|
209
|
+
gssapi (~> 1.2)
|
|
210
|
+
gyoku (~> 1.0)
|
|
211
|
+
httpclient (~> 2.2, >= 2.2.0.2)
|
|
212
|
+
logging (>= 1.6.1, < 3.0)
|
|
213
|
+
nori (~> 2.0)
|
|
214
|
+
rubyntlm (~> 0.6.0, >= 0.6.3)
|
|
215
|
+
winrm-elevated (1.2.3)
|
|
216
|
+
erubi (~> 1.8)
|
|
217
|
+
winrm (~> 2.0)
|
|
218
|
+
winrm-fs (~> 1.0)
|
|
219
|
+
winrm-fs (1.3.5)
|
|
220
|
+
erubi (~> 1.8)
|
|
221
|
+
logging (>= 1.6.1, < 3.0)
|
|
222
|
+
rubyzip (~> 2.0)
|
|
223
|
+
winrm (~> 2.0)
|
|
224
|
+
|
|
225
|
+
PLATFORMS
|
|
226
|
+
ruby
|
|
227
|
+
arm64-darwin
|
|
228
|
+
x86_64-darwin
|
|
229
|
+
x86_64-linux
|
|
230
|
+
|
|
231
|
+
DEPENDENCIES
|
|
232
|
+
rake (~> 13.0)
|
|
233
|
+
rspec (~> 3.0)
|
|
234
|
+
rubocop (~> 1.21)
|
|
235
|
+
train-f5!
|
|
236
|
+
|
|
237
|
+
BUNDLED WITH
|
|
238
|
+
2.2.32
|
data/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Train::F5
|
|
2
|
+
|
|
3
|
+
A simple [Train](https://github.com/inspec/train) plugin that wraps REST calls to F5 BigIP load balancers.
|
|
4
|
+
|
|
5
|
+
Train is used by Chef infrastructure automation products like Chef Infra and Chef Inspec to connect to
|
|
6
|
+
remote backends.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'train-f5'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
$ bundle install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or just install it yourself as:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
$ gem install train-f5
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To test the plugin using Inspec you can try:-
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
inspec detect -t f5://admin:secrit_pa55word@f5.myorg.com:8443 --insecure
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You should end up with output like this if all went well
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
─────── Platform Details ───────
|
|
38
|
+
|
|
39
|
+
Name: f5
|
|
40
|
+
Families: api
|
|
41
|
+
Release: 16.1.3.1
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Usage in Inspec profiles
|
|
46
|
+
|
|
47
|
+
To write an Inspec custom resource, you can use the following methods:-
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
json_body = inspec.backend.get(f5_rest_endpoint)
|
|
51
|
+
json_body = inspec.backend.put(f5_rest_endpoint, data)
|
|
52
|
+
json_body = inspec.backend.post(f5_rest_endpoint, data)
|
|
53
|
+
json_body = inspec.backend.delete(f5_rest_endpoint)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can experiment with the API using the Inspec Shell
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
inspec detect -t f5://admin:secrit_pa55word@f5.myorg.com:8443 --insecure
|
|
60
|
+
|
|
61
|
+
inspec.backend.get '/mgmt/tm/sys/version'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Example Custom Resource
|
|
65
|
+
|
|
66
|
+
_The custom resource_
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
# libraries/f5_software.rb
|
|
70
|
+
class F5Software < Inspec.resource(1)
|
|
71
|
+
name "f5_software"
|
|
72
|
+
|
|
73
|
+
def version
|
|
74
|
+
body = inspec.backend.get('/mgmt/tm/sys/version')
|
|
75
|
+
f5_release = body['entries'].values[0]['nestedStats']['entries']['Version']['description']
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
_The Control_
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
# controls/software.rb
|
|
84
|
+
control "Software - 1.1" do
|
|
85
|
+
impact 0.7
|
|
86
|
+
title "Version must be correct"
|
|
87
|
+
|
|
88
|
+
describe f5_software do
|
|
89
|
+
its('version') { should eq '16.1.3.0' }
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Credentials
|
|
95
|
+
|
|
96
|
+
You can pass credentials at the command line
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
inspec detect -t f5://admin:secrit_pa55word@f5.myorg.com:8443 --insecure
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You can also pass credentials in environment variables (useful to avoid creds on the command line)
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export F5_PORT=8443
|
|
106
|
+
export F5_HOST=f5.myorg.com
|
|
107
|
+
export F5_PASSWORD=secrit_pa55word
|
|
108
|
+
export F5_USER=admin
|
|
109
|
+
|
|
110
|
+
inspec detect -t f5:// --insecure
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Contributing
|
|
114
|
+
|
|
115
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/trickyearlobe/train-f5.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "train/f5"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "train"
|
|
4
|
+
require "train-f5/version"
|
|
5
|
+
require "train-f5/error"
|
|
6
|
+
require "faraday"
|
|
7
|
+
require "faraday_middleware"
|
|
8
|
+
|
|
9
|
+
module TrainPlugins
|
|
10
|
+
module F5
|
|
11
|
+
# F5 Connection
|
|
12
|
+
class Connection < Train::Plugins::Transport::BaseConnection
|
|
13
|
+
# Initialise Faraday as the HTTP handler with basic auth
|
|
14
|
+
# and automatic JSON conversion.
|
|
15
|
+
def initialize(options)
|
|
16
|
+
super(options)
|
|
17
|
+
@baseurl = "https://#{options[:host]}:#{options[:port]}"
|
|
18
|
+
@httpclient = Faraday.new(
|
|
19
|
+
url: @baseurl, ssl: { verify: !options[:insecure] },
|
|
20
|
+
headers: { "Content-Type" => "application/json", "Accept" => "application/json" }
|
|
21
|
+
) do |conn|
|
|
22
|
+
if Faraday::VERSION.split(".")[0] == "1"
|
|
23
|
+
conn.request :basic_auth, options[:user], options[:password]
|
|
24
|
+
else
|
|
25
|
+
conn.request :authorization, :basic, options[:user], options[:password]
|
|
26
|
+
end
|
|
27
|
+
conn.request :json
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Allow Train to query the platform we are connected to
|
|
32
|
+
def platform
|
|
33
|
+
body = get("/mgmt/tm/sys/version")
|
|
34
|
+
f5_release = body["entries"].values[0]["nestedStats"]["entries"]["Version"]["description"]
|
|
35
|
+
# f5_family = body['entries'].values[0]['nestedStats']['entries']['Product']['description']
|
|
36
|
+
Train::Platforms.name("f5").in_family("api")
|
|
37
|
+
force_platform!("f5", release: f5_release)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Do GET,PUT,POST, DELETE with the cached Faraday client
|
|
41
|
+
def get(uri)
|
|
42
|
+
process_response(@httpclient.get(uri))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def put(uri, data = nil)
|
|
46
|
+
process_response(@httpclient.put(uri, data))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def post(uri, data = nil)
|
|
50
|
+
process_response(@httpclient.post(uri, data))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def delete(uri)
|
|
54
|
+
process_response(@httpclient.delete(uri))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def process_response(resp)
|
|
58
|
+
JSON.parse(resp.body)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "train-f5/connection"
|
|
4
|
+
|
|
5
|
+
module TrainPlugins
|
|
6
|
+
module F5
|
|
7
|
+
# F5 Transport class for Train
|
|
8
|
+
class Transport < Train.plugin(1)
|
|
9
|
+
name "f5"
|
|
10
|
+
option :host, default: ENV["F5_HOST"]
|
|
11
|
+
option :insecure, default: false
|
|
12
|
+
option :user, default: ENV["F5_USER"]
|
|
13
|
+
option :port, default: ENV["F5_PORT"] || "443"
|
|
14
|
+
option :password, default: ENV["F5_PASSWORD"]
|
|
15
|
+
|
|
16
|
+
# Returns a cached connection to an F5 BigIP appliance
|
|
17
|
+
def connection(_instance_opts = nil)
|
|
18
|
+
@connection ||= TrainPlugins::F5::Connection.new(@options)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/train-f5.rb
ADDED
data/train-f5.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/train-f5/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "train-f5"
|
|
7
|
+
spec.version = TrainPlugins::F5::VERSION
|
|
8
|
+
spec.authors = ["Richard Nixon"]
|
|
9
|
+
spec.email = ["richard.nixon@btinternet"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "A Train plugin for F5 BigIP"
|
|
12
|
+
spec.description = "A Train plugin that allows Inspec to call the F5 REST API"
|
|
13
|
+
spec.homepage = "https://github.com/trickyearlobe/train-f5"
|
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
15
|
+
|
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
|
17
|
+
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
spec.add_dependency "faraday"
|
|
35
|
+
spec.add_dependency "faraday_middleware"
|
|
36
|
+
spec.add_dependency "train"
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: train-f5
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Richard Nixon
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-09-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: faraday
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: faraday_middleware
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: train
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description: A Train plugin that allows Inspec to call the F5 REST API
|
|
56
|
+
email:
|
|
57
|
+
- richard.nixon@btinternet
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".rspec"
|
|
63
|
+
- ".rubocop.yml"
|
|
64
|
+
- Gemfile
|
|
65
|
+
- Gemfile.lock
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/setup
|
|
70
|
+
- lib/train-f5.rb
|
|
71
|
+
- lib/train-f5/connection.rb
|
|
72
|
+
- lib/train-f5/error.rb
|
|
73
|
+
- lib/train-f5/transport.rb
|
|
74
|
+
- lib/train-f5/version.rb
|
|
75
|
+
- train-f5.gemspec
|
|
76
|
+
homepage: https://github.com/trickyearlobe/train-f5
|
|
77
|
+
licenses: []
|
|
78
|
+
metadata:
|
|
79
|
+
allowed_push_host: https://rubygems.org/
|
|
80
|
+
homepage_uri: https://github.com/trickyearlobe/train-f5
|
|
81
|
+
source_code_uri: https://github.com/trickyearlobe/train-f5
|
|
82
|
+
changelog_uri: https://github.com/trickyearlobe/train-f5
|
|
83
|
+
post_install_message:
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: 2.6.0
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubygems_version: 3.2.32
|
|
99
|
+
signing_key:
|
|
100
|
+
specification_version: 4
|
|
101
|
+
summary: A Train plugin for F5 BigIP
|
|
102
|
+
test_files: []
|