smart_proxy_ansible 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572320552523c1629bda9d963a16fd07d189f14a
|
4
|
+
data.tar.gz: 92d4fee5cbafedd4fc52b0921ca4f470374837f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9faca4cd728399491dd3a8edba30dc214d710ed237d12c95e5abaed7a58eccdc35ad79a2c894b8eeea1fc1723b2b05ed857eef8add79c102a51e4de2a7cb571
|
7
|
+
data.tar.gz: 3c908550293b98400efb727cd89e5f55537ff6b1616a364c78635dccb7fff8540a19845bba583547d3c637207192d91149a03dde215fa7df1334de8d897b70da
|
@@ -4,6 +4,8 @@ module Proxy
|
|
4
4
|
# please keep the actual implementation of the endpoints outside
|
5
5
|
# of this class.
|
6
6
|
class Api < Sinatra::Base
|
7
|
+
include ::Proxy::Log
|
8
|
+
|
7
9
|
get '/roles' do
|
8
10
|
RolesReader.list_roles.to_json
|
9
11
|
end
|
@@ -11,13 +13,23 @@ module Proxy
|
|
11
13
|
get '/roles/variables' do
|
12
14
|
variables = {}
|
13
15
|
RolesReader.list_roles.each do |role_name|
|
14
|
-
|
16
|
+
begin
|
17
|
+
variables[role_name] = extract_variables(role_name)[role_name]
|
18
|
+
rescue ReadVariablesException => e
|
19
|
+
# skip what cannot be parsed
|
20
|
+
logger.error e
|
21
|
+
end
|
15
22
|
end
|
16
23
|
variables.to_json
|
17
24
|
end
|
18
25
|
|
19
26
|
get '/roles/:role_name/variables' do |role_name|
|
20
|
-
|
27
|
+
begin
|
28
|
+
extract_variables(role_name).to_json
|
29
|
+
rescue ReadVariablesException => e
|
30
|
+
logger.error e
|
31
|
+
{}.to_json
|
32
|
+
end
|
21
33
|
end
|
22
34
|
|
23
35
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Proxy
|
2
4
|
module Ansible
|
3
5
|
# Implements the logic needed to read the roles and associated information
|
@@ -6,26 +8,16 @@ module Proxy
|
|
6
8
|
def extract_variables(role_path)
|
7
9
|
role_files = Dir.glob("#{role_path}/defaults/**/*.yml") +
|
8
10
|
Dir.glob("#{role_path}/defaults/**/*.yaml")
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
candidates.map do |variable|
|
20
|
-
variable.split('|').map(&:strip).select do |var|
|
21
|
-
!var.include?('(') && # variables are not parenthesis
|
22
|
-
!var.include?('[') && # variables are not arrays
|
23
|
-
!var.include?('.') && # variables are not objects
|
24
|
-
!var.include?("'") # variables are not plain strings
|
25
|
-
end
|
26
|
-
end unless candidates.nil?
|
27
|
-
end.compact.flatten.uniq.map(&:strip)
|
28
|
-
variables
|
11
|
+
role_files.flat_map do |role_file|
|
12
|
+
loaded_yaml = {}
|
13
|
+
begin
|
14
|
+
loaded_yaml = YAML.load_file(role_file)
|
15
|
+
rescue Psych::SyntaxError
|
16
|
+
raise ReadVariablesException.new "#{role_file} is not YAML file"
|
17
|
+
end
|
18
|
+
raise ReadVariablesException.new "Could not parse YAML file: #{role_file}" unless loaded_yaml.is_a? Hash
|
19
|
+
loaded_yaml.keys
|
20
|
+
end
|
29
21
|
end
|
30
22
|
end
|
31
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_ansible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|