puppetfactory 0.4.0

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.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +0 -0
  4. data/bin/pfsh +31 -0
  5. data/bin/puppetfactory +153 -0
  6. data/lib/puppetfactory.rb +300 -0
  7. data/lib/puppetfactory/cli.rb +114 -0
  8. data/lib/puppetfactory/dashboard/rake_tasks.rb +69 -0
  9. data/lib/puppetfactory/dashboard/serverspec_helper.rb +84 -0
  10. data/lib/puppetfactory/dashboard/spec_helper.rb +26 -0
  11. data/lib/puppetfactory/helpers.rb +37 -0
  12. data/lib/puppetfactory/monkeypatches.rb +30 -0
  13. data/lib/puppetfactory/plugins.rb +11 -0
  14. data/lib/puppetfactory/plugins/certificates.rb +28 -0
  15. data/lib/puppetfactory/plugins/classification.rb +75 -0
  16. data/lib/puppetfactory/plugins/code_manager.rb +156 -0
  17. data/lib/puppetfactory/plugins/console_user.rb +62 -0
  18. data/lib/puppetfactory/plugins/dashboard.rb +128 -0
  19. data/lib/puppetfactory/plugins/docker.rb +193 -0
  20. data/lib/puppetfactory/plugins/example.rb +88 -0
  21. data/lib/puppetfactory/plugins/github.rb +102 -0
  22. data/lib/puppetfactory/plugins/gitlab.rb +62 -0
  23. data/lib/puppetfactory/plugins/hooks.rb +46 -0
  24. data/lib/puppetfactory/plugins/login_shell.rb +10 -0
  25. data/lib/puppetfactory/plugins/logs.rb +34 -0
  26. data/lib/puppetfactory/plugins/r10k.rb +112 -0
  27. data/lib/puppetfactory/plugins/shell_user.rb +69 -0
  28. data/lib/puppetfactory/plugins/user_environment.rb +77 -0
  29. data/public/dashboard.js +100 -0
  30. data/public/font-awesome/css/font-awesome.css +2199 -0
  31. data/public/font-awesome/css/font-awesome.min.css +4 -0
  32. data/public/font-awesome/fonts/FontAwesome.otf +0 -0
  33. data/public/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  34. data/public/font-awesome/fonts/fontawesome-webfont.svg +685 -0
  35. data/public/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  36. data/public/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  37. data/public/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  38. data/public/gitviz/LICENSE.md +20 -0
  39. data/public/gitviz/README.md +13 -0
  40. data/public/gitviz/css/explaingit.css +227 -0
  41. data/public/gitviz/css/vendor/1140.css +130 -0
  42. data/public/gitviz/images/forkme_right_red_aa0000.png +0 -0
  43. data/public/gitviz/images/grippy-close.png +0 -0
  44. data/public/gitviz/images/grippy.png +0 -0
  45. data/public/gitviz/images/prompt.gif +0 -0
  46. data/public/gitviz/index.html +734 -0
  47. data/public/gitviz/js/controlbox.js +459 -0
  48. data/public/gitviz/js/explaingit.js +74 -0
  49. data/public/gitviz/js/historyview.js +979 -0
  50. data/public/gitviz/js/main.js +56 -0
  51. data/public/gitviz/js/vendor/d3.min.js +4 -0
  52. data/public/gitviz/js/vendor/jquery-latest.min.js +6 -0
  53. data/public/gitviz/js/vendor/normalize.css +396 -0
  54. data/public/gitviz/js/vendor/require.min.js +35 -0
  55. data/public/gitviz/memtest.html +44 -0
  56. data/public/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  57. data/public/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  58. data/public/images/ui-bg_flat_10_000000_40x100.png +0 -0
  59. data/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  60. data/public/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  61. data/public/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  62. data/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  63. data/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  64. data/public/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  65. data/public/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  66. data/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  67. data/public/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  68. data/public/images/ui-icons_222222_256x240.png +0 -0
  69. data/public/images/ui-icons_228ef1_256x240.png +0 -0
  70. data/public/images/ui-icons_454545_256x240.png +0 -0
  71. data/public/images/ui-icons_ef8c08_256x240.png +0 -0
  72. data/public/images/ui-icons_ffd27a_256x240.png +0 -0
  73. data/public/images/ui-icons_ffffff_256x240.png +0 -0
  74. data/public/jquery-1.11.1.min.js +4 -0
  75. data/public/jquery-ui.css +464 -0
  76. data/public/jquery-ui.min.css +7 -0
  77. data/public/jquery-ui.min.js +13 -0
  78. data/public/jquery-ui.structure.min.css +5 -0
  79. data/public/jquery-ui.theme.min.css +5 -0
  80. data/public/jquery.activity-indicator-1.0.0.min.js +10 -0
  81. data/public/jquery.js +9789 -0
  82. data/public/loginscripts.js +18 -0
  83. data/public/scripts.js +36 -0
  84. data/public/style.css +193 -0
  85. data/public/usermanagement.js +133 -0
  86. data/templates/init_scripts.erb +10 -0
  87. data/templates/puppet.conf.erb +10 -0
  88. data/templates/site.pp.erb +50 -0
  89. data/views/dashboard.erb +62 -0
  90. data/views/home.erb +43 -0
  91. data/views/index.erb +29 -0
  92. data/views/logs.erb +26 -0
  93. data/views/shell.erb +35 -0
  94. data/views/users.erb +69 -0
  95. metadata +256 -0
@@ -0,0 +1,18 @@
1
+ $(document).ready(function(){
2
+ $('#show-alternate').click( function(e) {
3
+ e.preventDefault();
4
+
5
+ $( "#alternate" ).dialog({
6
+ title: $(this).attr("title"),
7
+ buttons: {
8
+ Ok: function() {
9
+ $( this ).dialog( "close" );
10
+ }
11
+ },
12
+ open: function () {
13
+ $(this).parent().find('button:nth-child(1)').focus();
14
+ },
15
+ width: '500px',
16
+ });
17
+ });
18
+ });
data/public/scripts.js ADDED
@@ -0,0 +1,36 @@
1
+ $(document).ready(function(){
2
+ // activate tabs
3
+ $('#tabs').tabs({
4
+ beforeLoad: function (event, ui) {
5
+ var keepLoading = true;
6
+
7
+ // Is the <a> tag is classified with 'cache'?
8
+ if (ui.tab.children("a").first().hasClass("cache")) {
9
+ keepLoading = (ui.panel.html() == "");
10
+ }
11
+
12
+ if(ui.panel.html() == "") {
13
+ ui.panel.html('Loading...');
14
+ }
15
+
16
+ return keepLoading;
17
+ },
18
+ });
19
+
20
+ $('#login').button({
21
+ icons: {
22
+ primary: "ui-icon-locked"
23
+ }
24
+ });
25
+ });
26
+
27
+ function updatePage(name) {
28
+ if (name) {
29
+ var idx = $("#tabs > ul > li:contains("+name+")").index();
30
+ }
31
+ else {
32
+ var idx = $("#tabs").tabs("option","active");
33
+ }
34
+
35
+ $("#tabs").tabs('load', idx);
36
+ }
data/public/style.css ADDED
@@ -0,0 +1,193 @@
1
+ table {
2
+ width: 100%;
3
+ border: 1px solid #ccc;
4
+ background: #efefef;
5
+ border-spacing: 0;
6
+ -moz-border-radius: 5px;
7
+ border-radius: 5px;
8
+ }
9
+ tr.even {
10
+ background: #b3c6ae;
11
+ }
12
+
13
+ li {
14
+ margin-bottom: 0.5em;
15
+ }
16
+
17
+ #login {
18
+ position: absolute;
19
+ top: 0.5em;
20
+ right: 0.5em;
21
+ font-size: 8pt;
22
+ opacity: 0;
23
+ }
24
+ #login:hover {
25
+ opacity: 1;
26
+ }
27
+
28
+ #usercontent {
29
+ position: relative;
30
+ }
31
+
32
+ #newuserwrapper {
33
+ position: absolute;
34
+ top: 0;
35
+ right: 0;
36
+ }
37
+
38
+ #newuserwrapper.open {
39
+ border: 1px solid #cfcfcf;
40
+ padding: 0.5em;
41
+ background-color: rgba(0, 0, 0, 0.6);
42
+ }
43
+
44
+ #newuser {
45
+ display: none;
46
+ width: 16em;
47
+ margin-top: 0.5em;
48
+ }
49
+
50
+ #newuser table {
51
+ padding: 0.25em 0;
52
+ }
53
+
54
+ #newuser.processing table,
55
+ #newuser.processing table input {
56
+ background: #565656;
57
+ color: #2a2929;
58
+ }
59
+
60
+ #newuser.processing table {
61
+ border-color: #565656;
62
+ }
63
+
64
+ #newuser td.label {
65
+ text-align: right;
66
+ font-size: small;
67
+ font-weight: lighter;
68
+ }
69
+
70
+ #newuser table input.fail {
71
+ background: #f88484;
72
+ }
73
+
74
+ table#currentuser th.header {
75
+ width: 10%;
76
+ white-space: nowrap;
77
+ text-align: right;
78
+ padding-right: 1em;
79
+ }
80
+ table#currentuser tr.actions {
81
+ text-align: right;
82
+ }
83
+
84
+ table#users {
85
+ margin-top: 1em;
86
+ }
87
+
88
+ table#users th {
89
+ border-bottom: 2px solid #999;
90
+ }
91
+
92
+ table#users td {
93
+ border-right: 1px solid #ccc;
94
+ border-collapse: collapse;
95
+ padding: 0 0.5em;
96
+ text-align: center;
97
+ }
98
+
99
+ table#users td.select {
100
+ font-size: 0.8em;
101
+ }
102
+
103
+ #console {
104
+ width: 100%;
105
+ height: 24em;
106
+ }
107
+
108
+ #shell code {
109
+ background-color: #ddd;
110
+ border-bottom: 2px dotted #aaa;
111
+ padding: 0.25em;
112
+ }
113
+
114
+ #alternate,
115
+ #explanation {
116
+ display: none;
117
+ }
118
+
119
+ #show-alternate {
120
+ float: right;
121
+ margin-left: 0.5em;
122
+ }
123
+
124
+ #dashboard {
125
+
126
+ }
127
+
128
+ #dashboard #notifications {
129
+ font-size: 0.5em;
130
+ color: #666;
131
+ }
132
+
133
+ #dashboard #notifications.fail {
134
+ font-weight: bold;
135
+ background-color: red;
136
+ border: 1px solid black;
137
+ border-radius: 0.5em;
138
+ padding: 0.25em 0.5em;
139
+ }
140
+
141
+ #dashboard #tools {
142
+ float: right;
143
+ top: 1em;
144
+ font-size: 0.8em;
145
+ margin-bottom: 0.5em;
146
+ }
147
+
148
+ #dashboard #tools * {
149
+ font-size: 0.8em;
150
+ }
151
+
152
+ #dashboard #tools * .ui-button-text {
153
+ padding-top: 0.25em;
154
+ padding-bottom: 0.25em;
155
+ }
156
+
157
+ #dashboard .user {
158
+ border: 1px solid #ccc;
159
+ border-radius: 0.5em;
160
+ padding: 0 0.5em 0.5em;
161
+ margin: 0.5em 0;
162
+ clear: both;
163
+ }
164
+
165
+ #dashboard .gutter {
166
+ background-color: #ffdddd;
167
+ border-radius: 0.25em;
168
+ box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25) inset;
169
+ font-size: 0.8em;
170
+ }
171
+
172
+ #dashboard .gutter .label {
173
+ float: right;
174
+ padding-right: 1em;
175
+ }
176
+
177
+ #dashboard .completed {
178
+ white-space: nowrap;
179
+ overflow-x: visible;
180
+ background-color: #80f36f;
181
+ border-radius: 0.25em;
182
+ min-width: 0.25em;
183
+ border: 1px solid #666;
184
+ }
185
+
186
+ #dashboard .completed a {
187
+ font-size: 0.5em;
188
+ text-decoration: none;
189
+ }
190
+
191
+ #dashboard .completed a:hover {
192
+ border-bottom: 2px solid black;
193
+ }
@@ -0,0 +1,133 @@
1
+ $(document).ready(function(){
2
+
3
+ function validUsername(text) {
4
+ var legalChars = /^[a-z][a-z0-9]{2,}$/; // Allow only letters for first character and then alphanumeric
5
+ if (!legalChars.test(text)) {
6
+ alert("Usernames must be at least 3 lowercase alphanumeric characters and start with a letter\n");
7
+ return false;
8
+ };
9
+ return true;
10
+ };
11
+
12
+ function open() {
13
+ $('#showuser').hide();
14
+ $('#newuserwrapper').addClass("open");
15
+ $('#newuser').slideDown("fast");
16
+ $('#user').focus();
17
+ }
18
+
19
+ function close() {
20
+ $('#showuser').show();
21
+ $('#newuserwrapper').removeClass("open");
22
+ $('#newuser').hide();
23
+ }
24
+
25
+ function start_processing() {
26
+ $('#newuser input[type=button]').attr("disabled", true);
27
+ $('#newuser').addClass("processing");
28
+ $('#newuser table').activity({width: 5.5, space: 6, length: 13});
29
+ }
30
+
31
+ function stop_processing() {
32
+ $('#newuser').removeClass("processing");
33
+ $('#newuser input[type=button]').attr("disabled", false);
34
+ $('#newuser table').activity(false);
35
+ }
36
+
37
+ function failing(item) {
38
+ item.attr("value", "");
39
+ item.addClass("fail");
40
+ item.focus();
41
+ }
42
+
43
+ // toggle hide the newuser dialog
44
+ $('#showuser').click(function(){
45
+ open();
46
+ });
47
+ $('#hideuser').click(function(){
48
+ close();
49
+ });
50
+
51
+ $('#users .select a').click(function(event){
52
+ event.preventDefault();
53
+ var action = $(this).attr('href');
54
+
55
+ $.get(action, function(data) {
56
+ updatePage();
57
+ });
58
+ });
59
+
60
+ // save the new user
61
+ $('#save').click(function(){
62
+ var username = $('#user').val();
63
+ var password = $('#password').val();
64
+ var password2 = $('#password2').val();
65
+ var session = $('#session').val();
66
+
67
+ // reset warnings
68
+ $('#user').removeClass("fail");
69
+ $('#password').removeClass("fail");
70
+ $('#password2').removeClass("fail");
71
+ $('#session').removeClass("fail");
72
+
73
+ if(!validUsername(username)) {
74
+ failing($('#user'));
75
+ }
76
+ else if(password == '' || password != password2) {
77
+ failing($('#password'));
78
+ failing($('#password2'));
79
+ }
80
+ else if(session == '') {
81
+ failing($('#session'));
82
+ }
83
+ else {
84
+ start_processing();
85
+
86
+ $.post('/new', {username: username, password: password, session: session}, function(data) {
87
+ console.log(data);
88
+ var results = jQuery.parseJSON(data);
89
+ if(results.status == 'success') {
90
+ updatePage();
91
+ }
92
+ else {
93
+ stop_processing();
94
+ alert("Could not create user:\n" + results.message);
95
+ }
96
+ }).fail(function(jqXHR) {
97
+ stop_processing();
98
+ alert("Could not create user:\n" + jqXHR.responseText);
99
+ });
100
+
101
+ }
102
+
103
+ });
104
+
105
+ $('#deploy').click(function(){
106
+ var button = $(this);
107
+ var activity = button.siblings('i');
108
+ var username = button.attr("data-user");
109
+
110
+ activity.addClass('fa-spinner fa-spin');
111
+ button.attr("disabled", true);
112
+ $.ajax({
113
+ url: '/api/users/'+username,
114
+ type: 'PUT',
115
+ data: "action=deploy",
116
+ success: function(response) {
117
+ var results = jQuery.parseJSON(response);
118
+
119
+ activity.removeClass('fa-spinner fa-spin');
120
+ button.attr("disabled", false);
121
+
122
+ if(results.status != 'success') {
123
+ alert("Deploy failed. See logs for details.");
124
+ }
125
+ },
126
+ error: function(response) {
127
+ activity.removeClass('fa-spinner fa-spin');
128
+ alert("Deploy failed:\n" + response.responseText);
129
+ }
130
+ });
131
+ });
132
+
133
+ });
@@ -0,0 +1,10 @@
1
+ [Unit]
2
+ Description=docker-<%= username %>
3
+
4
+ [Service]
5
+ ExecStart=/bin/docker start -a <%= username %>
6
+ ExecStop=/bin/docker stop <%= username %>
7
+ Restart=on-failure
8
+
9
+ [Install]
10
+ WantedBy=default.target
@@ -0,0 +1,10 @@
1
+ [main]
2
+ certname = <%= username %>.puppetlabs.vm
3
+ server = <%= @master %>
4
+ basemodulepath = /root/puppetcode/modules:/etc/puppetlabs/code/modules
5
+
6
+ [agent]
7
+ report = true
8
+ classfile = $vardir/classes.txt
9
+ localconfig = $vardir/localconfig
10
+ pluginsync = true
@@ -0,0 +1,50 @@
1
+ ## site.pp ##
2
+
3
+ # This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
4
+ # used when an agent connects to a master and asks for an updated configuration.
5
+ #
6
+ # Global objects like filebuckets and resource defaults should go in this file,
7
+ # as should the default node definition. (The default node can be omitted
8
+ # if you use the console and don't define any other nodes in site.pp. See
9
+ # http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
10
+ # node definitions.)
11
+
12
+ ## Active Configurations ##
13
+
14
+ # Disable filebucket by default for all File resources:
15
+ File { backup => false }
16
+
17
+ # DEFAULT NODE
18
+ # Node definitions in this file are merged with node data from the console. See
19
+ # http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
20
+ # node definitions.
21
+
22
+ # The default node definition matches any node lacking a more specific node
23
+ # definition. If there are no other nodes in this file, classes declared here
24
+ # will be included in every node's catalog, *in addition* to any classes
25
+ # specified in the console for that node.
26
+
27
+ # Make Puppet shut up about allow_virtual
28
+ Package {
29
+ allow_virtual => false,
30
+ }
31
+
32
+ node default {
33
+ # This is where you can declare classes for all nodes.
34
+ # Example:
35
+ # class { 'my_class': }
36
+ <% unless @modulepath == :none %>
37
+ unless $::osfamily == 'windows' {
38
+ file { '<%= @codedir %>/environments/production/modules':
39
+ ensure => link,
40
+ force => true,
41
+ target => '<%= @puppetcode %>/modules',
42
+ }
43
+ file { '<%= @codedir %>/environments/production/manifests':
44
+ ensure => link,
45
+ force => true,
46
+ target => '<%= @puppetcode %>/manifests',
47
+ }
48
+ }
49
+ <% end %>
50
+ }