Skip to content

Commit cc8ec16

Browse files
committed
Refs #35184 - Drop puppetca_http_api provider
While cc1cee8 already formally dropped support for Puppet, the code was still present and Foreman Proxy supported it too. In Foreman Proxy 3.4 the old puppetca_puppet_cert provider is dropped, meaning this is dead code anyway. The puppetca_http_api provider is ensured absent to clean up the config file. For compatibility with Foreman Proxy < 3.4 the puppet_version version is set to 6.0. This forces the puppetca_http_api provider to be used and a static value means fewer service restarts. Foreman Proxy >= 3.4 ignores this setting altogether. This gets rids of various top level parameters, which simplifies things. No care is taken to clean up sudo entries. It is assumed users already upgraded to Puppet 6 in which case the module previously cleaned up the entries. The proper upgrade path is to upgrade to Puppet 6 using theforeman/foreman_proxy 22.x and only then upgrade the module to the latest version.
1 parent d9d7926 commit cc8ec16

File tree

7 files changed

+13
-100
lines changed

7 files changed

+13
-100
lines changed

manifests/config.pp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@
8989
contain foreman_proxy::module::puppetca
9090
foreman_proxy::provider { ['puppetca_hostname_whitelisting', 'puppetca_token_whitelisting']:
9191
}
92-
foreman_proxy::provider { ['puppetca_http_api', 'puppetca_puppet_cert']:
92+
foreman_proxy::provider { 'puppetca_http_api':
93+
}
94+
# Foreman Proxy 3.4 dropped puppetca_puppet_cert
95+
foreman_proxy::provider { 'puppetca_puppet_cert':
96+
ensure => absent,
9397
}
9498

9599
contain foreman_proxy::module::realm
@@ -104,29 +108,8 @@
104108

105109
contain foreman_proxy::module::registration
106110

107-
if $foreman_proxy::puppetca or $foreman_proxy::puppet {
108-
$uses_sudo = $foreman_proxy::puppetca and versioncmp($facts['puppetversion'], '6.0') < 0
109-
110-
if $foreman_proxy::use_sudoersd {
111-
if $uses_sudo and $foreman_proxy::manage_sudoersd {
112-
ensure_resource('file', "${foreman_proxy::sudoers}.d", { 'ensure' => 'directory' })
113-
}
114-
115-
file { "${foreman_proxy::sudoers}.d/foreman-proxy":
116-
ensure => bool2str($uses_sudo, 'file', 'absent'),
117-
owner => 'root',
118-
group => 0,
119-
mode => '0440',
120-
content => template('foreman_proxy/sudo.erb'),
121-
}
122-
} elsif $foreman_proxy::use_sudoers {
123-
augeas { 'sudo-foreman-proxy':
124-
context => "/files${foreman_proxy::sudoers}",
125-
changes => template('foreman_proxy/sudo_augeas.erb'),
126-
}
127-
}
128-
} else {
129-
# The puppet-agent (puppet 4 AIO package) doesn't create a puppet user and group
111+
unless $foreman_proxy::puppetca or $foreman_proxy::puppet {
112+
# The puppet-agent doesn't create a puppet user and group
130113
# but the foreman proxy still needs to be able to read the agent's private key
131114
if $foreman_proxy::manage_puppet_group and $foreman_proxy::ssl {
132115
if !defined(Group[$foreman_proxy::puppet_group]) {

manifests/init.pp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@
4848
#
4949
# $trusted_hosts:: Only hosts listed will be permitted, empty array to disable authorization
5050
#
51-
# $manage_sudoersd:: Whether to manage File['/etc/sudoers.d'] or not. When reusing this module, this may be
52-
# disabled to let a dedicated sudo module manage it instead.
53-
#
54-
# $use_sudoersd:: Add a file to /etc/sudoers.d (true).
55-
#
56-
# $use_sudoers:: Add contents to /etc/sudoers (true). This is ignored if $use_sudoersd is true.
57-
#
5851
# $puppetca:: Enable Puppet CA feature
5952
#
6053
# $puppetca_listen_on:: Protocols for the Puppet CA feature to listen on
@@ -65,8 +58,6 @@
6558
#
6659
# $puppetdir:: Puppet var directory
6760
#
68-
# $puppetca_cmd:: Puppet CA command to be allowed in sudoers
69-
#
7061
# $puppet_group:: Groups of Foreman proxy user
7162
#
7263
# $autosignfile:: Hostname-Whitelisting only: Location of puppets autosign.conf
@@ -308,14 +299,10 @@
308299
Array[String] $trusted_hosts = $foreman_proxy::params::trusted_hosts,
309300
Array[String] $ssl_disabled_ciphers = [],
310301
Array[String] $tls_disabled_versions = [],
311-
Boolean $manage_sudoersd = true,
312-
Boolean $use_sudoersd = true,
313-
Boolean $use_sudoers = true,
314302
Boolean $puppetca = true,
315303
Foreman_proxy::ListenOn $puppetca_listen_on = 'https',
316304
Stdlib::Absolutepath $ssldir = $foreman_proxy::params::ssldir,
317305
Stdlib::Absolutepath $puppetdir = $foreman_proxy::params::puppetdir,
318-
String $puppetca_cmd = $foreman_proxy::params::puppetca_cmd,
319306
String $puppet_group = 'puppet',
320307
String $puppetca_provider = 'puppetca_hostname_whitelisting',
321308
Stdlib::Absolutepath $autosignfile = $foreman_proxy::params::autosignfile,

manifests/params.pp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,10 @@
130130
# Only hosts listed will be permitted, empty array to disable authorization
131131
$trusted_hosts = [$lower_fqdn]
132132

133-
$sudoers = "${etc}/sudoers"
134-
135133
# puppet settings
136134
$puppet_url = "https://${facts['networking']['fqdn']}:8140"
137135

138136
# puppetca settings
139-
$puppetca_cmd = "${puppet_cmd} cert"
140137
$autosignfile = "${puppetdir}/autosign.conf"
141138

142139
# Template settings

spec/classes/foreman_proxy__spec.rb

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
'---',
229229
':enabled: https',
230230
':use_provider: puppetca_hostname_whitelisting',
231-
":puppet_version: #{Puppet.version}",
231+
":puppet_version: '6.0'",
232232
])
233233
end
234234

@@ -242,11 +242,8 @@
242242
])
243243
end
244244

245-
it 'should generate correct puppetca_puppet_cert.yml' do
246-
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppetca_puppet_cert.yml", [
247-
'---',
248-
":ssldir: #{ssl_dir}",
249-
])
245+
it 'should remove puppetca_puppet_cert.yml' do
246+
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/puppetca_puppet_cert.yml").with_ensure('absent')
250247
end
251248

252249
it 'should generate correct puppetca_hostname_whitelisting.yml' do
@@ -321,27 +318,6 @@
321318
])
322319
end
323320

324-
it 'should set up sudo rules', if: Puppet.version < '6.0' do
325-
should contain_file("#{etc_dir}/sudoers.d").with_ensure('directory')
326-
327-
should contain_file("#{etc_dir}/sudoers.d/foreman-proxy").with({
328-
:ensure => 'file',
329-
:owner => 'root',
330-
:group => 0,
331-
:mode => '0440',
332-
})
333-
334-
verify_exact_contents(catalogue, "#{etc_dir}/sudoers.d/foreman-proxy", [
335-
"#{proxy_user_name} ALL = (root) NOPASSWD : #{puppetca_command}",
336-
"Defaults:#{proxy_user_name} !requiretty",
337-
])
338-
end
339-
340-
it 'should not set up sudo rules', if: Puppet.version >= '6.0' do
341-
should_not contain_file("#{etc_dir}/sudoers.d")
342-
should contain_file("#{etc_dir}/sudoers.d/foreman-proxy").with_ensure('absent')
343-
end
344-
345321
it "should not manage puppet group" do
346322
should_not contain_group('puppet')
347323
end
@@ -736,17 +712,6 @@
736712
end
737713
end
738714

739-
context 'when puppetca_cmd set', if: Puppet.version < '6.0' do
740-
let(:params) { super().merge(puppetca_cmd: 'pup cert') }
741-
742-
it "should set puppetca_cmd" do
743-
verify_exact_contents(catalogue, "#{etc_dir}/sudoers.d/foreman-proxy", [
744-
"#{proxy_user_name} ALL = (root) NOPASSWD : pup cert *",
745-
"Defaults:#{proxy_user_name} !requiretty",
746-
])
747-
end
748-
end
749-
750715
context 'with custom puppetca params' do
751716
let(:params) do
752717
super().merge(
@@ -764,7 +729,7 @@
764729
'---',
765730
':enabled: https',
766731
':use_provider: puppetca_token_whitelisting',
767-
":puppet_version: #{Puppet.version}",
732+
":puppet_version: '6.0'",
768733
])
769734
end
770735

templates/puppetca.yml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
# - puppetca_token_whitelisting (verify CSRs based on a token whitelist)
99
:use_provider: <%= scope.lookupvar("foreman_proxy::puppetca_provider") %>
1010

11-
# Puppet version used
12-
:puppet_version: <%= @puppetversion %>
11+
# Using 6.0 forces use of puppetca_http_api
12+
:puppet_version: '6.0'

templates/sudo.erb

Lines changed: 0 additions & 2 deletions
This file was deleted.

templates/sudo_augeas.erb

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)