Skip to content

Commit b6d6178

Browse files
committed
support for passing file URIs to manual
1 parent 06ca6f6 commit b6d6178

File tree

3 files changed

+220
-46
lines changed

3 files changed

+220
-46
lines changed

doc/puppet_defined_types/sshkeys_3A_3Amanual.html

Lines changed: 179 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ <h2>Overview</h2>
7474

7575
<p>Sshkeys::Manual</p>
7676

77-
<p>Manually import a set of ssh keys for a given user</p>
77+
<p>Manually import a set of ssh keys for a given user. File can be supplied
78+
inline as strings or via URIs suitable for the <code>source</code>
79+
attribute of the puppet <code>file</code> resource. It is an error to
80+
specify both <code>content</code> and <code>source</code></p>
7881

7982
</div>
8083
</div>
@@ -93,6 +96,11 @@ <h2>Overview</h2>
9396
<em class="default">(defaults to: <tt>$title</tt>)</em>
9497

9598

99+
&mdash;
100+
<div class='inline'>
101+
<p>User to install keys for</p>
102+
</div>
103+
96104
</li>
97105

98106
<li>
@@ -106,6 +114,12 @@ <h2>Overview</h2>
106114
<em class="default">(defaults to: <tt>&quot;/home&quot;</tt>)</em>
107115

108116

117+
&mdash;
118+
<div class='inline'>
119+
<p>Location of home directories. All files will be created inside
120+
<code>$home/$user</code></p>
121+
</div>
122+
109123
</li>
110124

111125
<li>
@@ -119,6 +133,11 @@ <h2>Overview</h2>
119133
<em class="default">(defaults to: <tt>undef</tt>)</em>
120134

121135

136+
&mdash;
137+
<div class='inline'>
138+
<p>Group that will own the installed keys</p>
139+
</div>
140+
122141
</li>
123142

124143
<li>
@@ -132,6 +151,30 @@ <h2>Overview</h2>
132151
<em class="default">(defaults to: <tt>undef</tt>)</em>
133152

134153

154+
&mdash;
155+
<div class='inline'>
156+
<p>Content of the regular <code>id_rsa</code> (private key) file</p>
157+
</div>
158+
159+
</li>
160+
161+
<li>
162+
163+
<span class='name'>id_rsa</span>
164+
165+
166+
<span class='type'></span>
167+
168+
169+
<em class="default">(defaults to: <tt>undef</tt>)</em>
170+
171+
172+
&mdash;
173+
<div class='inline'>
174+
<p>Source of the regular <code>id_rsa</code> (private key) file. This can be
175+
any location understood by the puppet <code>file</code> resource</p>
176+
</div>
177+
135178
</li>
136179

137180
<li>
@@ -145,6 +188,30 @@ <h2>Overview</h2>
145188
<em class="default">(defaults to: <tt>undef</tt>)</em>
146189

147190

191+
&mdash;
192+
<div class='inline'>
193+
<p>Content of the regular <code>id_rsa.pub</code> (public key) file</p>
194+
</div>
195+
196+
</li>
197+
198+
<li>
199+
200+
<span class='name'>id_rsa_pub_file</span>
201+
202+
203+
<span class='type'>(<tt>Any</tt>)</span>
204+
205+
206+
<em class="default">(defaults to: <tt>undef</tt>)</em>
207+
208+
209+
&mdash;
210+
<div class='inline'>
211+
<p>Source of the regular <code>id_rsa_pub</code> (public key) file. This can
212+
be any location understood by the puppet <code>file</code> resource</p>
213+
</div>
214+
148215
</li>
149216

150217
<li>
@@ -158,6 +225,30 @@ <h2>Overview</h2>
158225
<em class="default">(defaults to: <tt>undef</tt>)</em>
159226

160227

228+
&mdash;
229+
<div class='inline'>
230+
<p>Content of the regular <code>known_hosts</code> file</p>
231+
</div>
232+
233+
</li>
234+
235+
<li>
236+
237+
<span class='name'>known_hosts_file</span>
238+
239+
240+
<span class='type'>(<tt>Any</tt>)</span>
241+
242+
243+
<em class="default">(defaults to: <tt>undef</tt>)</em>
244+
245+
246+
&mdash;
247+
<div class='inline'>
248+
<p>Source of the regular <code>known_hosts</code> file. This can be any
249+
location understood by the puppet <code>file</code> resource</p>
250+
</div>
251+
161252
</li>
162253

163254
<li>
@@ -171,6 +262,43 @@ <h2>Overview</h2>
171262
<em class="default">(defaults to: <tt>undef</tt>)</em>
172263

173264

265+
&mdash;
266+
<div class='inline'>
267+
<p>Content of the regular <code>authorized_keys</code> file</p>
268+
</div>
269+
270+
</li>
271+
272+
<li>
273+
274+
<span class='name'>authorized_keys_file</span>
275+
276+
277+
<span class='type'>(<tt>Any</tt>)</span>
278+
279+
280+
<em class="default">(defaults to: <tt>undef</tt>)</em>
281+
282+
283+
&mdash;
284+
<div class='inline'>
285+
<p>Source of the regular <code>authorized_keys</code> file. This can be any
286+
location understood by the puppet <code>file</code> resource</p>
287+
</div>
288+
289+
</li>
290+
291+
<li>
292+
293+
<span class='name'>id_rsa_file</span>
294+
295+
296+
<span class='type'>(<tt>Any</tt>)</span>
297+
298+
299+
<em class="default">(defaults to: <tt>undef</tt>)</em>
300+
301+
174302
</li>
175303

176304
</ul>
@@ -183,25 +311,6 @@ <h2>Overview</h2>
183311
<pre class="lines">
184312

185313

186-
4
187-
5
188-
6
189-
7
190-
8
191-
9
192-
10
193-
11
194-
12
195-
13
196-
14
197-
15
198-
16
199-
17
200-
18
201-
19
202-
20
203-
21
204-
22
205314
23
206315
24
207316
25
@@ -245,19 +354,51 @@ <h2>Overview</h2>
245354
63
246355
64
247356
65
248-
66</pre>
357+
66
358+
67
359+
68
360+
69
361+
70
362+
71
363+
72
364+
73
365+
74
366+
75
367+
76
368+
77
369+
78
370+
79
371+
80
372+
81
373+
82
374+
83
375+
84
376+
85
377+
86
378+
87
379+
88
380+
89
381+
90
382+
91
383+
92
384+
93
385+
94</pre>
249386
</td>
250387
<td>
251-
<pre class="code"><span class="info file"># File 'manifests/manual.pp', line 4</span>
388+
<pre class="code"><span class="info file"># File 'manifests/manual.pp', line 23</span>
252389

253390
define sshkeys::manual(
254-
$user = $title,
255-
$home = &quot;/home&quot;,
256-
$group = undef,
257-
$id_rsa = undef,
258-
$id_rsa_pub = undef,
259-
$known_hosts = undef,
260-
$authorized_keys = undef,
391+
$user = $title,
392+
$home = &quot;/home&quot;,
393+
$group = undef,
394+
$id_rsa = undef,
395+
$id_rsa_file = undef,
396+
$id_rsa_pub = undef,
397+
$id_rsa_pub_file = undef,
398+
$known_hosts = undef,
399+
$known_hosts_file = undef,
400+
$authorized_keys = undef,
401+
$authorized_keys_file = undef,
261402
) {
262403

263404
if $group {
@@ -266,19 +407,19 @@ <h2>Overview</h2>
266407
$_group = $user
267408
}
268409

269-
$id_rsa_present = $id_rsa ? {
410+
$id_rsa_present = pick($id_rsa, $id_rsa_file) ? {
270411
undef =&gt; &#39;absent&#39;,
271412
default =&gt; &#39;present&#39;
272413
}
273-
$id_rsa_pub_present = $id_rsa_pub ? {
414+
$id_rsa_pub_present = pick($id_rsa_pub, $id_rsa_pub_file) ? {
274415
undef =&gt; &#39;absent&#39;,
275416
default =&gt; &#39;present&#39;
276417
}
277-
$known_hosts_present = $known_hosts ? {
418+
$known_hosts_present = pick($known_hosts, $known_hosts_file) ? {
278419
undef =&gt; &#39;absent&#39;,
279420
default =&gt; &#39;present&#39;
280421
}
281-
$authorized_keys_present = $authorized_keys ? {
422+
$authorized_keys_present = pick($authorized_keys, $authorized_keys_file) ? {
282423
undef =&gt; &#39;absent&#39;,
283424
default =&gt; &#39;present&#39;
284425
}
@@ -293,24 +434,29 @@ <h2>Overview</h2>
293434
ensure =&gt; directory,
294435
}
295436

437+
296438
file { &quot;${home}/.ssh/id_rsa&quot;:
297439
ensure =&gt; $id_rsa_present,
298440
content =&gt; $id_rsa,
441+
source =&gt; $id_rsa_file,
299442
}
300443

301444
file { &quot;${home}/.ssh/id_rsa.pub&quot;:
302445
ensure =&gt; $id_rsa_pub_present,
303446
content =&gt; $id_rsa_pub,
447+
source =&gt; $id_rsa_pub_file,
304448
}
305449

306450
file { &quot;${home}/.ssh/authorized_keys&quot;:
307451
ensure =&gt; $authorized_keys_present,
308452
content =&gt; $authorized_keys,
453+
source =&gt; $authorized_keys_file,
309454
}
310455

311456
file { &quot;${home}/.ssh/known_hosts&quot;:
312457
ensure =&gt; $known_hosts_present,
313458
content =&gt; $known_hosts,
459+
source =&gt; $known_hosts_file,
314460
}
315461
}</pre>
316462
</td>

0 commit comments

Comments
 (0)