salt-api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/salt/api.rb +2 -0
- data/lib/salt/api/run.rb +19 -0
- data/lib/salt/api/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe9a4ef81da864ac063adcf8395bcd525bf668ae
|
4
|
+
data.tar.gz: 2fd665f9c80083d03cce40a6956b2cccc031bc0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37670e0c4712b16f7ee1fc04fb8d8500d6d762e10e591a6562e08ea2c91837f4861a3026ae6e1c8e20661d65243f8efab5ba8e88a7248f6bf8cbb0df9fa05e3e
|
7
|
+
data.tar.gz: 382de37d0717b03f5374a7546d9e4da7967038aa0fd8bf806f8fc732d31008c9d70ec2f2e86a90eb530b7892d388125a76d640756df7a08722e92cf5743d8a17
|
data/README.md
CHANGED
@@ -35,6 +35,16 @@ end
|
|
35
35
|
puts Salt::Api.minions
|
36
36
|
```
|
37
37
|
|
38
|
+
```
|
39
|
+
require 'salt/api'
|
40
|
+
|
41
|
+
Salt::Api.run(
|
42
|
+
client: 'local',
|
43
|
+
tgt: '*',
|
44
|
+
fun: 'test.ping'
|
45
|
+
)
|
46
|
+
```
|
47
|
+
|
38
48
|
## Development
|
39
49
|
|
40
50
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/salt/api.rb
CHANGED
@@ -3,6 +3,7 @@ require "salt/api/configure"
|
|
3
3
|
require "salt/api/client"
|
4
4
|
require "salt/api/minions"
|
5
5
|
require "salt/api/events"
|
6
|
+
require "salt/api/run"
|
6
7
|
|
7
8
|
module Salt
|
8
9
|
module Api
|
@@ -10,5 +11,6 @@ module Salt
|
|
10
11
|
extend Client
|
11
12
|
extend Minions
|
12
13
|
extend Events
|
14
|
+
extend Run
|
13
15
|
end
|
14
16
|
end
|
data/lib/salt/api/run.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Salt
|
2
|
+
module Api
|
3
|
+
module Run
|
4
|
+
def run(args)
|
5
|
+
req = Net::HTTP::Post.new("/")
|
6
|
+
req['X-Auth-Token'] = token
|
7
|
+
req['Accept'] = "application/x-yaml"
|
8
|
+
req['Content-Type'] = "application/json"
|
9
|
+
req.body = args.to_json
|
10
|
+
|
11
|
+
resp = client.request(req)
|
12
|
+
raise "Get request to /run failed (#{resp})" unless resp.kind_of? Net::HTTPSuccess
|
13
|
+
parsed_resp = YAML.load(resp.body)["return"]
|
14
|
+
raise "Multiple results? (#{parsed_resp.inspect})" if parsed_resp.length > 1
|
15
|
+
parsed_resp.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/salt/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salt-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua B. Bussdieker
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/salt/api/configure.rb
|
88
88
|
- lib/salt/api/events.rb
|
89
89
|
- lib/salt/api/minions.rb
|
90
|
+
- lib/salt/api/run.rb
|
90
91
|
- lib/salt/api/version.rb
|
91
92
|
- salt-api.gemspec
|
92
93
|
homepage: https://github.com/jbussdieker/ruby-salt-api
|