puppetfactory 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +269 -0
- data/lib/puppetfactory/plugins/docker.rb +4 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a157b1822c0f0d849c9e6736f9db2ea764bca2b8
|
4
|
+
data.tar.gz: b9c3b8627880c59db823a11df611aa62763b82b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23c88a71bc7f9705d393ddfd6a6a3469778e383cf2ef785a3f642e00755c5c1f5ab5f1f118fe16b9f986203fa3d0ca9b91864c713df1a2610d0559f8a8e5aad
|
7
|
+
data.tar.gz: 5bb210b884ee679433c5aa31fd9ac184606c71d6a314159659fa2873fccdb99a39d03a60291028515c3fa7e0407881d987ec304584eeeff40919b54a2b71bfca
|
data/README.md
CHANGED
@@ -0,0 +1,269 @@
|
|
1
|
+
PuppetFactory
|
2
|
+
=============
|
3
|
+
|
4
|
+
## Customizable user account management.
|
5
|
+
|
6
|
+
Walking students through the PE installation process is counterproductive.
|
7
|
+
Requiring them to manage their own virtual machine and debug networking issues
|
8
|
+
takes up a great deal of classroom time.
|
9
|
+
|
10
|
+
This project was designed to eliminate that need. Students can create user
|
11
|
+
accounts with the click of a button, allowing them to work along with exercises
|
12
|
+
without the overhead of managing a full VM.
|
13
|
+
|
14
|
+
Puppetfactory is pluggable and highly configurable. By default, it provides just
|
15
|
+
a user account and a standard shell login embedded in a web page. Add in the
|
16
|
+
Docker plugin and that user account then logs into a container. Add in the
|
17
|
+
Classification plugin and PE Console node groups and classification rules will
|
18
|
+
be managed automatically. Add in either the R10k or CodeManager plugin and
|
19
|
+
sources will be managed, allowing the user to deploy a codebase from a
|
20
|
+
control repository.
|
21
|
+
|
22
|
+
The accompanying `pltraining/puppetfactory` Puppet module will build a Docker
|
23
|
+
image suitable for fully comprehensive Puppet agent nodes and stand up the
|
24
|
+
components of the Puppetfactory stack.
|
25
|
+
|
26
|
+
Users should have their shell set to `pfsh`, which is located in `/usr/local/bin`
|
27
|
+
by default. It will request the current session ID, and then invoke the `login`
|
28
|
+
action of whichever plugin is currently configured.
|
29
|
+
|
30
|
+
![Screenshot](screenshot.png)
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
### Puppet training classes
|
35
|
+
|
36
|
+
If this is being used for a Puppet training class, each course should have a
|
37
|
+
`pltraining/classroom` profile associated with it. The module should be
|
38
|
+
installed into the global modulepath
|
39
|
+
|
40
|
+
1. Start with a standard Puppetlabs Training Master VM
|
41
|
+
1. `puppet module install pltraining/classroom --modulepath /etc/puppetlabs/code/modules`
|
42
|
+
1. Classify the master with `classroom::course::<name>`.
|
43
|
+
1. Load up [http://${ipaddress}](http://${ipaddress}) in a browser.
|
44
|
+
1. Write the URL on the board and start class.
|
45
|
+
|
46
|
+
Students will need to use the _Users_ tab to create their accounts. This tab
|
47
|
+
will also list all known users along with statuses, including useful information
|
48
|
+
about their accounts; certname, Console login, etc.
|
49
|
+
|
50
|
+
They can use their username to SSH to the master, either from their own client
|
51
|
+
or from the _SSH Login_ tab. Their Console login will use the same password.
|
52
|
+
|
53
|
+
### Other usage
|
54
|
+
|
55
|
+
Run `puppetfactory configprint` to get a printout of all the configuration
|
56
|
+
settings. If no config file exists, this will be all the default options. To
|
57
|
+
change any of the options, add them to the `/etc/puppetfactory/config.yaml`
|
58
|
+
config file.
|
59
|
+
|
60
|
+
Most of the options are self explanatory. Some that you may want to configure
|
61
|
+
include:
|
62
|
+
|
63
|
+
* `:port`
|
64
|
+
* The port number to listen on.
|
65
|
+
* `:bind`
|
66
|
+
* Which interface to bind to. The default of `0.0.0.0` means bind to all.
|
67
|
+
* `:user`
|
68
|
+
* The username for admin level access.
|
69
|
+
* `:password`
|
70
|
+
* The password for admin level access.
|
71
|
+
* `:session`
|
72
|
+
* The session ID used to create accounts or log in.
|
73
|
+
|
74
|
+
Container options:
|
75
|
+
|
76
|
+
* `:puppetcode`
|
77
|
+
* The path to a folder mapped into the user's container.
|
78
|
+
* `:modulepath`
|
79
|
+
* How the user's modulepath should be mounted.
|
80
|
+
* Valid options: `:readwrite`, `:readonly`, or `:none`
|
81
|
+
|
82
|
+
Code management options:
|
83
|
+
|
84
|
+
* `:gitserver`, `:gituser`, `:controlrepo`
|
85
|
+
* The URL to the git server where the control repo lives.
|
86
|
+
* The username owning the control repo.
|
87
|
+
* The name of the control repo
|
88
|
+
* `:repomodel`
|
89
|
+
* Whether the students will work in branches or maintain prefixed forks of the control repo.
|
90
|
+
* Valid options: `:single`, `:peruser`
|
91
|
+
|
92
|
+
|
93
|
+
#### Enabling plugins
|
94
|
+
|
95
|
+
Enable plugins to configure how Puppetfactory works by adding them to the `:plugins` option:
|
96
|
+
|
97
|
+
:plugins:
|
98
|
+
- :Certificates
|
99
|
+
- :Classification
|
100
|
+
- :Docker
|
101
|
+
- :Logs
|
102
|
+
- :Dashboard
|
103
|
+
- :CodeManager
|
104
|
+
- :ShellUser
|
105
|
+
|
106
|
+
List of current plugins:
|
107
|
+
|
108
|
+
* `:Certificates`
|
109
|
+
* Removes signed certificates when the user is removed.
|
110
|
+
* `:Classification`
|
111
|
+
* Manages PE Console node groups and classification rules for each user.
|
112
|
+
* `:CodeManager`
|
113
|
+
* Manages Code Manager sources for each user.
|
114
|
+
* Deploys code into each user's environment.
|
115
|
+
* `:ConsoleUser`
|
116
|
+
* Creates a PE Console user account for each user.
|
117
|
+
* `:Dashboard`
|
118
|
+
* Spec testing dashboard shows current progress through labs.
|
119
|
+
* Only enabled for a limited number of classes.
|
120
|
+
* Configure with:
|
121
|
+
* `:dashboard_path`
|
122
|
+
* Where the spec tests reside.
|
123
|
+
* `:dashboard_interval`
|
124
|
+
* How often the dashboard should update in seconds.
|
125
|
+
* `:Docker`
|
126
|
+
* Manages Docker containers for users.
|
127
|
+
* Configure with:
|
128
|
+
* `:container_name`
|
129
|
+
* The name of the image to build containers from.
|
130
|
+
* Defaults to 'centosagent'
|
131
|
+
* `:privileged`
|
132
|
+
* Whether containers should start in privileged mode.
|
133
|
+
* Currently required for `systemd`.
|
134
|
+
* `:Github`
|
135
|
+
* Adds user branches and permissions to the control repo when running with a single repo.
|
136
|
+
* Displays a link to the user's control repo or branch.
|
137
|
+
* Adds a link to the user's last commit.
|
138
|
+
* Configure with:
|
139
|
+
* `:githubtoken`
|
140
|
+
* A Github application token with admin rights on the control repo.
|
141
|
+
* Not needed for displaying links unless the control repo is private.
|
142
|
+
* Keep in mind that the token gives **full API access**. Treat it as a
|
143
|
+
password. If you pass it as a class parameter, you probably want
|
144
|
+
to put it in Hiera instead of in the PE Console, since other users
|
145
|
+
can view parameter values and reports.
|
146
|
+
* `:Gitlab`
|
147
|
+
* Manages Gitlab accounts for users.
|
148
|
+
* Expects a default Gitlab container to be running.
|
149
|
+
* `:Gitviz`
|
150
|
+
* Adds a tab displaying a customized git visualization.
|
151
|
+
* Adapted from https://github.com/onlywei/explain-git-with-d3
|
152
|
+
* `:Hooks`
|
153
|
+
* Run hook scripts on user creation and deletion.
|
154
|
+
* Configure with:
|
155
|
+
* `:hooks_path`
|
156
|
+
* Path to the hook scripts.
|
157
|
+
* `:LoginShell`
|
158
|
+
* When enabled, logging in with `pfsh` will run the system shell.
|
159
|
+
* `:Logs`
|
160
|
+
* Adds a tab displaying the Puppetfactory logfile.
|
161
|
+
* `:R10k`
|
162
|
+
* Manages `r10k` sources for each user.
|
163
|
+
* Deploys code into each user's environment.
|
164
|
+
* `:ShellUser`
|
165
|
+
* Mananges system accounts for each user.
|
166
|
+
* Required for any plugins expecting to set user permissions or map directories.
|
167
|
+
* `:UserEnvironment`
|
168
|
+
* When not using a control repo, this will create a default Puppet environment.
|
169
|
+
|
170
|
+
|
171
|
+
### Extending Puppetfactory with plugins
|
172
|
+
|
173
|
+
Puppetfactory's plugin model is simple. Each time an action is called, that action
|
174
|
+
is invoked on each plugin that exposes it. That means that if your plugin has a
|
175
|
+
method named `create`, then it will be invoked with two arguments, (the new user's
|
176
|
+
*username* and *password*) each time a new user is created.
|
177
|
+
|
178
|
+
Plugins are sorted by their `weight` property, low to high. The default weight is
|
179
|
+
100, and the `ShellUser` weight is 1, indicating that it should run first when enabled.
|
180
|
+
|
181
|
+
See the `Example` plugin in `lib/puppetfactory/plugins/example.rb` for an
|
182
|
+
explanation of each action. The plugin class name must match the filename, where
|
183
|
+
the class name is `CamelCased` and the file is `snake_cased`.
|
184
|
+
|
185
|
+
Plugins can also add new tabs and new web routes. See the `Logs` plugin for a
|
186
|
+
simple example of that.
|
187
|
+
|
188
|
+
|
189
|
+
### Components
|
190
|
+
|
191
|
+
Several components and services work together to make up the Puppetfactory
|
192
|
+
stack. It's recommended to use the `pltraining/puppetfactory` module to manage
|
193
|
+
the full stack.
|
194
|
+
|
195
|
+
#### PuppetFactory gem
|
196
|
+
|
197
|
+
This is the actual graphical Web UI allowing the students to interact with the
|
198
|
+
system. It allows students to create their own user account and provides a tab
|
199
|
+
for an SSH console login.
|
200
|
+
|
201
|
+
#### Abalone
|
202
|
+
|
203
|
+
This is the web terminal embedded in the SSH console tab.
|
204
|
+
|
205
|
+
#### Nginx
|
206
|
+
|
207
|
+
This is used to proxy the services into a cohesive whole, including exposing
|
208
|
+
HTTP for each student container if configured to do so.
|
209
|
+
|
210
|
+
#### Docker
|
211
|
+
|
212
|
+
The default container service used by Puppetfactory. This provides students full
|
213
|
+
root access to their own Puppet agent node.
|
214
|
+
|
215
|
+
|
216
|
+
## Troubleshooting and recovery
|
217
|
+
|
218
|
+
Because we're using docker containers for the student environments there are a
|
219
|
+
few things you can do to troubleshoot.
|
220
|
+
|
221
|
+
Run `puppetfactory --help` on the master to see commands to create, remove, or
|
222
|
+
repair user accounts.
|
223
|
+
|
224
|
+
If you need to access a student environment:
|
225
|
+
|
226
|
+
* `su - #{username}`
|
227
|
+
|
228
|
+
To interact directly with a container (assuming the Docker plugin):
|
229
|
+
|
230
|
+
* `docker start #{username}`
|
231
|
+
* `docker stop #{username}`
|
232
|
+
* `docker info #{username}`
|
233
|
+
|
234
|
+
The containers also have valid init scripts so they can be start/stopped with:
|
235
|
+
|
236
|
+
* `systemctl start docker-#{username}`
|
237
|
+
* `systemctl stop docker-#{username}`
|
238
|
+
|
239
|
+
|
240
|
+
## RESTlike usage
|
241
|
+
|
242
|
+
Users can be created by treating the classroom manager like a RESTful API:
|
243
|
+
|
244
|
+
* `curl --data 'username=fooh&password=bar' admin:admin@localhost/new`
|
245
|
+
|
246
|
+
There are also the following RESTful API endpoints:
|
247
|
+
|
248
|
+
* `GET /api/users`
|
249
|
+
- The current users with container status
|
250
|
+
* `GET /api/users/:username`
|
251
|
+
- Same as users but only the user indicated
|
252
|
+
* `GET /api/users/:username/port`
|
253
|
+
- The port on the host which is mapped to port 80 on the container
|
254
|
+
* `GET /api/users/:username/node_group_status`
|
255
|
+
- Status of the PE node group
|
256
|
+
* `GET /api/users/:username/consoe_user_status`
|
257
|
+
- Status of the PE console user
|
258
|
+
* `POST /api/users`
|
259
|
+
- Create a new user, container, node group, and console user
|
260
|
+
* `DELETE /api/users/:username`
|
261
|
+
- Remove all trace of the user, container, etc.
|
262
|
+
|
263
|
+
Note: These are mostly intended for use in a future UI, but they can be helpful for troubleshooting.
|
264
|
+
|
265
|
+
|
266
|
+
## Acknowledgements
|
267
|
+
|
268
|
+
Special thanks to Britt Gresham for the inspiration for this project:
|
269
|
+
https://github.com/demophoon/webvim
|
@@ -29,10 +29,12 @@ class Puppetfactory::Plugins::Docker < Puppetfactory::Plugins
|
|
29
29
|
def create(username, password)
|
30
30
|
begin
|
31
31
|
environment = "#{@environments}/#{Puppetfactory::Helpers.environment_name(username)}"
|
32
|
-
|
33
32
|
binds = [
|
34
33
|
"/var/yum:/var/yum",
|
35
|
-
"/var/cache
|
34
|
+
"/var/cache:/var/cache",
|
35
|
+
"/etc/pki/rpm-gpg:/etc/pki/rpm-gpg",
|
36
|
+
"/etc/yum.repos.d:/etc/yum.repos.d",
|
37
|
+
"/opt/puppetlabs/server:/opt/puppetlabs/server",
|
36
38
|
"/home/#{username}/puppet:#{@confdir}",
|
37
39
|
"/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
38
40
|
]
|
metadata
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetfactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Ford
|
8
8
|
- Josh Samuelson
|
9
|
+
- Michael Marrero
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2017-
|
13
|
+
date: 2017-06-28 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: sinatra
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
requirements:
|
18
|
-
- -
|
19
|
+
- - '='
|
19
20
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
21
|
+
version: 1.4.8
|
21
22
|
type: :runtime
|
22
23
|
prerelease: false
|
23
24
|
version_requirements: !ruby/object:Gem::Requirement
|
24
25
|
requirements:
|
25
|
-
- -
|
26
|
+
- - '='
|
26
27
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
+
version: 1.4.8
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
30
|
name: json_pure
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|