3
0

Merge branch 'jenkins-build-11' into 'master'

Auto-merge for build 11

See merge request puppet/puppet_cd!9
This commit is contained in:
2025-10-23 14:52:56 +00:00
4 changed files with 210 additions and 5 deletions

View File

@@ -1470,6 +1470,24 @@
</li>
<li>
<span class='name'>pt_r10k_webhook_pkg</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;python3-pip&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>the packages for the r10k webhook</p>
</div>
</li>
<li>
<span class='name'>pt_manage_user</span>
@@ -1481,6 +1499,11 @@
<em class="default">(defaults to: <tt>true</tt>)</em>
&mdash;
<div class='inline'>
<p>whether to manage the puppet user</p>
</div>
</li>
</ul>
@@ -1494,8 +1517,6 @@
<pre class="lines">
86
87
88
89
90
@@ -1648,10 +1669,18 @@
237
238
239
240</pre>
240
241
242
243
244
245
246
247
248</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 86</span>
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 88</span>
class puppet_cd::params (
@@ -1665,6 +1694,7 @@ class puppet_cd::params (
String $pt_server_pkg = &#39;puppetserver&#39;,
Array $pt_db_pkg = [&#39;puppetdb&#39;,&#39;puppetdb-termini&#39;],
Array $pt_r10k_pkg = [&#39;ruby&#39;,&#39;ruby-devel&#39;,&#39;gcc&#39;,&#39;make&#39;,&#39;redhat-rpm-config&#39;,&#39;rpm-build&#39;],
String $pt_r10k_webhook_pkg = &#39;python3-pip&#39;,
# user settings
## puppet user
@@ -1770,6 +1800,7 @@ class puppet_cd::params (
$pt_puppetdb_var_dir = &#39;/opt/puppetlabs/server/data/puppetdb&#39;
## r10k
$pt_r10k_dir = &quot;${pt_main_dir}/r10k&quot;
$pt_r10k_webhook_dir = &#39;/opt/r10k-webhook&#39;
# files
## puppet
@@ -1798,6 +1829,10 @@ class puppet_cd::params (
## r10k
$pt_r10k_file = &quot;${pt_r10k_dir}/r10k.yaml&quot;
$pt_r10k_erb = &#39;puppet_cd/r10k/r10k.yaml.erb&#39;
$pt_r10k_webhook_file = &quot;${pt_r10k_webhook_dir}/webhook_server.py&quot;
$pt_r10k_webhook_erb = &#39;puppet_cd/r10k/webhook.py.erb&#39;
$pt_r10k_req_file = &quot;${pt_r10k_webhook_dir}/requirements.txt&quot;
$pt_r10k_req_erb = &#39;puppet_cd/r10k/requirements.txt.erb&#39;
# service
$pt_server_service = &#39;puppetserver&#39;

View File

@@ -105,7 +105,61 @@
7
8
9
10</pre>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/r10k/webhook.pp', line 6</span>
@@ -113,7 +167,61 @@
class puppet_cd::r10k::webhook (
) inherits puppet_cd::params {
if ($pt_pm_fqdn == $fqdn) and ($pt_use_r10k_webhook == true) {
# install packages
package { $pt_r10k_webhook_pkg:
ensure =&gt; $pt_pkg_ensure,
}
# create the webhook dir
file { &#39;/opt/r10k-webhook&#39;:
ensure =&gt; directory,
path =&gt; $pt_r10k_webhook_dir,
owner =&gt; &#39;puppet&#39;,
group =&gt; &#39;puppet&#39;,
mode =&gt; &#39;0755&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; puppet_etc_t,
seluser =&gt; system_u,
}
# create the requirements file
file { $pt_r10k_req_file:
ensure =&gt; file,
owner =&gt; &#39;puppet&#39;,
group =&gt; &#39;puppet&#39;,
mode =&gt; &#39;0644&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; puppet_etc_t,
seluser =&gt; system_u,
content =&gt; template($pt_r10k_req_erb),
require =&gt; File[&#39;/opt/r10k-webhook&#39;],
}
# create the binary file
file { $pt_r10k_webhook_file:
ensure =&gt; file,
owner =&gt; &#39;puppet&#39;,
group =&gt; &#39;puppet&#39;,
mode =&gt; &#39;0644&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; puppet_etc_t,
seluser =&gt; system_u,
content =&gt; template($pt_r10k_webhook_erb),
require =&gt; File[&#39;/opt/r10k-webhook&#39;],
}
# install pip dependencies
exec { &#39;pip_install_r10k_webhook&#39;:
command =&gt; &#39;pip3 install --user -r /opt/r10k-webhook/requirements.txt&#39;,
user =&gt; &#39;puppet&#39;,
require =&gt; [Package[$pt_r10k_webhook_pkg],File[$pt_r10k_req_file]],
unless =&gt; &#39;pip3 show fastapi&#39;, # Idempotent check
}
}
}</pre>
</td>
</tr>

View File

@@ -82,6 +82,8 @@
# @param [String] pt_r10k_remote the remote url for the r10k control repo
# @param [Boolean] pt_r10k_prefix the r10k prefix. defaults to false
# @param [String] pt_r10k_basedir the base directory for r10k.yaml
# @param [String] pt_r10k_webhook_pkg the packages for the r10k webhook
# @param [Boolean] pt_manage_user whether to manage the puppet user
###############################################################################
class puppet_cd::params (
@@ -95,6 +97,7 @@ class puppet_cd::params (
String $pt_server_pkg = 'puppetserver',
Array $pt_db_pkg = ['puppetdb','puppetdb-termini'],
Array $pt_r10k_pkg = ['ruby','ruby-devel','gcc','make','redhat-rpm-config','rpm-build'],
String $pt_r10k_webhook_pkg = 'python3-pip',
# user settings
## puppet user
@@ -200,6 +203,7 @@ class puppet_cd::params (
$pt_puppetdb_var_dir = '/opt/puppetlabs/server/data/puppetdb'
## r10k
$pt_r10k_dir = "${pt_main_dir}/r10k"
$pt_r10k_webhook_dir = '/opt/r10k-webhook'
# files
## puppet
@@ -228,6 +232,10 @@ class puppet_cd::params (
## r10k
$pt_r10k_file = "${pt_r10k_dir}/r10k.yaml"
$pt_r10k_erb = 'puppet_cd/r10k/r10k.yaml.erb'
$pt_r10k_webhook_file = "${pt_r10k_webhook_dir}/webhook_server.py"
$pt_r10k_webhook_erb = 'puppet_cd/r10k/webhook.py.erb'
$pt_r10k_req_file = "${pt_r10k_webhook_dir}/requirements.txt"
$pt_r10k_req_erb = 'puppet_cd/r10k/requirements.txt.erb'
# service
$pt_server_service = 'puppetserver'

View File

@@ -6,5 +6,59 @@
class puppet_cd::r10k::webhook (
) inherits puppet_cd::params {
if ($pt_pm_fqdn == $fqdn) and ($pt_use_r10k_webhook == true) {
# install packages
package { $pt_r10k_webhook_pkg:
ensure => $pt_pkg_ensure,
}
# create the webhook dir
file { '/opt/r10k-webhook':
ensure => directory,
path => $pt_r10k_webhook_dir,
owner => 'puppet',
group => 'puppet',
mode => '0755',
selrange => s0,
selrole => object_r,
seltype => puppet_etc_t,
seluser => system_u,
}
# create the requirements file
file { $pt_r10k_req_file:
ensure => file,
owner => 'puppet',
group => 'puppet',
mode => '0644',
selrange => s0,
selrole => object_r,
seltype => puppet_etc_t,
seluser => system_u,
content => template($pt_r10k_req_erb),
require => File['/opt/r10k-webhook'],
}
# create the binary file
file { $pt_r10k_webhook_file:
ensure => file,
owner => 'puppet',
group => 'puppet',
mode => '0644',
selrange => s0,
selrole => object_r,
seltype => puppet_etc_t,
seluser => system_u,
content => template($pt_r10k_webhook_erb),
require => File['/opt/r10k-webhook'],
}
# install pip dependencies
exec { 'pip_install_r10k_webhook':
command => 'pip3 install --user -r /opt/r10k-webhook/requirements.txt',
user => 'puppet',
require => [Package[$pt_r10k_webhook_pkg],File[$pt_r10k_req_file]],
unless => 'pip3 show fastapi', # Idempotent check
}
}
}