puppetfactory 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppetfactory/plugins/classification.rb +9 -10
- data/lib/puppetfactory/plugins/tree.rb +45 -0
- data/lib/puppetfactory/plugins/user_environment.rb +21 -6
- data/public/css/style.css +1 -0
- data/public/jstree-3.3.3/jstree.js +8305 -0
- data/public/jstree-3.3.3/jstree.min.js +6 -0
- data/public/jstree-3.3.3/themes/default/32px.png +0 -0
- data/public/jstree-3.3.3/themes/default/40px.png +0 -0
- data/public/jstree-3.3.3/themes/default/style.css +1102 -0
- data/public/jstree-3.3.3/themes/default/style.min.css +1 -0
- data/public/jstree-3.3.3/themes/default/throbber.gif +0 -0
- data/public/jstree-3.3.3/themes/default-dark/32px.png +0 -0
- data/public/jstree-3.3.3/themes/default-dark/40px.png +0 -0
- data/public/jstree-3.3.3/themes/default-dark/style.css +1146 -0
- data/public/jstree-3.3.3/themes/default-dark/style.min.css +1 -0
- data/public/jstree-3.3.3/themes/default-dark/throbber.gif +0 -0
- data/views/index.erb +2 -0
- data/views/users.erb +13 -0
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3defebfd3eeeeb27423a7f864e73ffc131eb44ad
|
4
|
+
data.tar.gz: c33e1dcf1f4df1641b615b35bbba212cad039bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7048bcca8e6508c619e97733b70b1f150799d1f47cb74ae8416bc7cc0a03202d7b0ea35f2c9a81050216ec8bfb6944d2a59798344e91f539204d80ec152da27a
|
7
|
+
data.tar.gz: 10a5e94ece8c2eae39d357d60e6ab0ac345b60b373458f9a4f0c57bd4845bf29f8eb4aa20e72de56f5fdc91db8f02023821e3fdb600d2de8a0c5fd00ebb99710
|
@@ -23,10 +23,10 @@ class Puppetfactory::Plugins::Classification < Puppetfactory::Plugins
|
|
23
23
|
|
24
24
|
def create(username, password)
|
25
25
|
environment = Puppetfactory::Helpers.environment_name(username)
|
26
|
-
certname
|
26
|
+
certname = "#{username}.#{@suffix}"
|
27
27
|
|
28
28
|
group_hash = {
|
29
|
-
'name' =>
|
29
|
+
'name' => "#{username}'s environment group",
|
30
30
|
'environment' => environment,
|
31
31
|
'environment_trumps' => true,
|
32
32
|
'parent' => '00000000-0000-4000-8000-000000000000',
|
@@ -37,26 +37,25 @@ class Puppetfactory::Plugins::Classification < Puppetfactory::Plugins
|
|
37
37
|
begin
|
38
38
|
@puppetclassify.groups.create_group(group_hash)
|
39
39
|
rescue => e
|
40
|
-
$logger.error "Could not create node group #{
|
40
|
+
$logger.error "Could not create node group for #{username}: #{e.message}"
|
41
41
|
return false
|
42
42
|
end
|
43
43
|
|
44
|
-
$logger.info "Created node group #{certname} assigned to environment #{environment}"
|
44
|
+
$logger.info "Created node group for #{certname} assigned to environment #{environment}"
|
45
45
|
true
|
46
46
|
end
|
47
47
|
|
48
48
|
def delete(username)
|
49
|
-
certname = "#{username}.#{@suffix}"
|
50
49
|
|
51
50
|
begin
|
52
|
-
group_id = @puppetclassify.groups.get_group_id(
|
51
|
+
group_id = @puppetclassify.groups.get_group_id("#{username}'s environment group")
|
53
52
|
@puppetclassify.groups.delete_group(group_id)
|
54
53
|
rescue => e
|
55
|
-
$logger.warn "Error removing node group #{
|
54
|
+
$logger.warn "Error removing node group for #{username}: #{e.message}"
|
56
55
|
return false
|
57
56
|
end
|
58
57
|
|
59
|
-
$logger.info "Node group #{
|
58
|
+
$logger.info "Node group #{username} removed"
|
60
59
|
true
|
61
60
|
end
|
62
61
|
|
@@ -65,9 +64,9 @@ class Puppetfactory::Plugins::Classification < Puppetfactory::Plugins
|
|
65
64
|
certname = "#{username}.#{@suffix}"
|
66
65
|
|
67
66
|
begin
|
68
|
-
ngid = @puppetclassify.groups.get_group_id(
|
67
|
+
ngid = @puppetclassify.groups.get_group_id("#{username}'s environment group")
|
69
68
|
rescue => e
|
70
|
-
$logger.warn "Error retrieving node group #{certname}: #{e.message}"
|
69
|
+
$logger.warn "Error retrieving node group for #{certname}: #{e.message}"
|
71
70
|
return nil
|
72
71
|
end
|
73
72
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'puppetfactory'
|
2
|
+
|
3
|
+
# inherit from Puppetfactory::Plugins
|
4
|
+
class Puppetfactory::Plugins::Tree < Puppetfactory::Plugins
|
5
|
+
attr_reader :weight
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
super(options) # call the superclass to initialize it
|
9
|
+
|
10
|
+
@weight = 1
|
11
|
+
@environments = options[:environments]
|
12
|
+
end
|
13
|
+
|
14
|
+
def userinfo(username, extended = false)
|
15
|
+
# we can bail if we don't want to add to the basic user object.
|
16
|
+
# for example, if these are heavy operations.
|
17
|
+
return unless extended
|
18
|
+
environment = Puppetfactory::Helpers.environment_name(username)
|
19
|
+
|
20
|
+
# return a hash with the :username key
|
21
|
+
{
|
22
|
+
:username => username,
|
23
|
+
:tree => pathwalker("#{@environments}/#{environment}", '#' ).to_json,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def pathwalker(path, parent)
|
28
|
+
accumulator = []
|
29
|
+
Dir.glob("#{path}/*").each do |file|
|
30
|
+
filename = File.basename file
|
31
|
+
|
32
|
+
# this way .fixtures.yml, etc will show up
|
33
|
+
next if ['.', '..'].include? filename
|
34
|
+
|
35
|
+
if File.directory?(file)
|
36
|
+
accumulator << { "id" => file, "parent" => parent, "text" => filename }
|
37
|
+
accumulator << pathwalker(file, file)
|
38
|
+
else
|
39
|
+
accumulator << { "id" => file, "parent" => parent, "icon" => "jstree-file", "text" => filename }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
accumulator.flatten
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'restclient'
|
2
3
|
require 'puppetfactory'
|
3
4
|
|
4
5
|
class Puppetfactory::Plugins::UserEnvironment < Puppetfactory::Plugins
|
@@ -6,6 +7,8 @@ class Puppetfactory::Plugins::UserEnvironment < Puppetfactory::Plugins
|
|
6
7
|
def initialize(options)
|
7
8
|
super(options)
|
8
9
|
|
10
|
+
@master = options[:master]
|
11
|
+
@confdir = options[:confdir]
|
9
12
|
@codedir = options[:codedir]
|
10
13
|
@stagedir = options[:stagedir]
|
11
14
|
@puppetcode = options[:puppetcode]
|
@@ -52,11 +55,8 @@ class Puppetfactory::Plugins::UserEnvironment < Puppetfactory::Plugins
|
|
52
55
|
end
|
53
56
|
|
54
57
|
def delete(username)
|
55
|
-
|
56
|
-
FileUtils.rm_rf
|
57
|
-
|
58
|
-
# also delete any prefixed environments. Is this even a good idea?
|
59
|
-
FileUtils.rm_rf "#{@environments}/#{username}_*" if @repomodel == :peruser
|
58
|
+
FileUtils.rm_rf "#{@codestage}/#{Puppetfactory::Helpers.environment_name(username)}"
|
59
|
+
FileUtils.rm_rf "#{@environments}/#{Puppetfactory::Helpers.environment_name(username)}"
|
60
60
|
end
|
61
61
|
|
62
62
|
def deploy(username)
|
@@ -64,7 +64,22 @@ class Puppetfactory::Plugins::UserEnvironment < Puppetfactory::Plugins
|
|
64
64
|
return if @codestage == @environments
|
65
65
|
environment = Puppetfactory::Helpers.environment_name(username)
|
66
66
|
|
67
|
-
|
67
|
+
begin
|
68
|
+
FileUtils.cp_r("#{@codestage}/#{environment}/*", "#{@environments}/#{environment}/")
|
69
|
+
FileUtils.chown_R('pe-puppet', 'pe-puppet', "#{@environments}/#{environment}")
|
70
|
+
|
71
|
+
RestClient::Resource.new(
|
72
|
+
"https://#{@master}:8140/puppet-admin-api/v1/environment-cache?environment=#{environment}",
|
73
|
+
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("#{@confdir}/ssl/certs/#{@master}.pem")),
|
74
|
+
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read("#{@confdir}/ssl/private_keys/#{@master}.pem")),
|
75
|
+
:ssl_ca_file => "#{@confdir}/ssl/ca/ca_crt.pem",
|
76
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER
|
77
|
+
).delete
|
78
|
+
rescue => e
|
79
|
+
$logger.error "Deploying environment #{environment} failed: #{e.message}"
|
80
|
+
$logger.debug e.backtrace
|
81
|
+
raise "Error deploying environment #{environment}."
|
82
|
+
end
|
68
83
|
end
|
69
84
|
|
70
85
|
def redeploy(username)
|