Showing with 935 additions and 597 deletions.
  1. +0 −2 .sync.yml
  2. +35 −0 CHANGELOG.md
  3. +1 −1 Gemfile
  4. +71 −0 HISTORY.md
  5. +1 −1 README.md
  6. +137 −0 lib/puppet/provider/foreman_global_parameter/rest_v3.rb
  7. +17 −3 lib/puppet/provider/foreman_resource/rest_v3.rb
  8. +65 −0 lib/puppet/type/foreman_global_parameter.rb
  9. +9 −9 manifests/cli.pp
  10. +3 −27 manifests/cli/params.pp
  11. +2 −2 manifests/compute/ec2.pp
  12. +2 −2 manifests/compute/gce.pp
  13. +2 −2 manifests/compute/libvirt.pp
  14. +2 −2 manifests/compute/openstack.pp
  15. +2 −2 manifests/compute/ovirt.pp
  16. +2 −2 manifests/compute/vmware.pp
  17. +13 −4 manifests/config.pp
  18. +5 −5 manifests/config/apache.pp
  19. +3 −3 manifests/config/apache/fragment.pp
  20. +2 −3 manifests/database.pp
  21. +2 −12 manifests/database/postgresql.pp
  22. +77 −81 manifests/init.pp
  23. +0 −8 manifests/install.pp
  24. +3 −131 manifests/params.pp
  25. +1 −2 manifests/plugin.pp
  26. +1 −1 manifests/plugin/abrt.pp
  27. +1 −1 manifests/plugin/acd.pp
  28. +1 −1 manifests/plugin/ansible.pp
  29. +1 −1 manifests/plugin/azure.pp
  30. +1 −1 manifests/plugin/bootdisk.pp
  31. +1 −2 manifests/plugin/chef.pp
  32. +1 −1 manifests/plugin/column_view.pp
  33. +1 −1 manifests/plugin/datacenter.pp
  34. +2 −2 manifests/plugin/default_hostgroup.pp
  35. +1 −1 manifests/plugin/dhcp_browser.pp
  36. +1 −1 manifests/plugin/digitalocean.pp
  37. +1 −1 manifests/plugin/discovery.pp
  38. +1 −1 manifests/plugin/dlm.pp
  39. +1 −1 manifests/plugin/docker.pp
  40. +8 −0 manifests/plugin/git_templates.pp
  41. +1 −1 manifests/plugin/hooks.pp
  42. +1 −1 manifests/plugin/host_reports.pp
  43. +1 −1 manifests/plugin/kubevirt.pp
  44. +1 −1 manifests/plugin/leapp.pp
  45. +1 −1 manifests/plugin/memcache.pp
  46. +8 −0 manifests/plugin/netbox.pp
  47. +1 −1 manifests/plugin/openscap.pp
  48. +1 −1 manifests/plugin/ovirt_provision.pp
  49. +1 −1 manifests/plugin/puppet.pp
  50. +1 −1 manifests/plugin/remote_execution.pp
  51. +2 −2 manifests/plugin/remote_execution/cockpit.pp
  52. +1 −1 manifests/plugin/rescue.pp
  53. +1 −1 manifests/plugin/rh_cloud.pp
  54. +1 −2 manifests/plugin/salt.pp
  55. +8 −0 manifests/plugin/scc_manager.pp
  56. +1 −1 manifests/plugin/setup.pp
  57. +1 −1 manifests/plugin/spacewalk.pp
  58. +1 −1 manifests/plugin/statistics.pp
  59. +1 −1 manifests/plugin/tasks.pp
  60. +1 −1 manifests/plugin/templates.pp
  61. +8 −0 manifests/plugin/vault.pp
  62. +1 −1 manifests/plugin/webhooks.pp
  63. +1 −1 manifests/plugin/wreckingball.pp
  64. +2 −2 manifests/providers.pp
  65. +2 −17 manifests/providers/params.pp
  66. +6 −6 manifests/rake.pp
  67. +2 −28 manifests/repo.pp
  68. +5 −11 manifests/repos.pp
  69. +4 −4 manifests/service.pp
  70. +10 −10 manifests/settings.pp
  71. +1 −10 metadata.json
  72. +8 −12 spec/acceptance/foreman_cli_plugins_spec.rb
  73. +76 −0 spec/acceptance/foreman_global_parameter_spec.rb
  74. +2 −6 spec/acceptance/foreman_journald_spec.rb
  75. +0 −11 spec/acceptance/hieradata/os/RedHat/7.yaml
  76. +0 −1 spec/classes/foreman_database_spec.rb
  77. +1 −43 spec/classes/foreman_repo_spec.rb
  78. +1 −3 spec/classes/foreman_service_spec.rb
  79. +4 −5 spec/classes/foreman_spec.rb
  80. +5 −0 spec/classes/plugin/git_templates_spec.rb
  81. +5 −0 spec/classes/plugin/netbox_spec.rb
  82. +1 −1 spec/classes/plugin/ovirt_provision_spec.rb
  83. +1 −1 spec/classes/plugin/puppetdb_spec.rb
  84. +2 −2 spec/classes/plugin/remote_execution_cockpit_spec.rb
  85. +5 −0 spec/classes/plugin/scc_manager_spec.rb
  86. +1 −1 spec/classes/plugin/tasks_spec.rb
  87. +5 −0 spec/classes/plugin/vault_spec.rb
  88. +1 −1 spec/defines/foreman_rake_spec.rb
  89. +3 −3 spec/defines/foreman_repos_apt_spec.rb
  90. +0 −19 spec/defines/foreman_repos_spec.rb
  91. +0 −8 spec/setup_acceptance_node.pp
  92. +2 −0 spec/spec_helper.rb
  93. +1 −8 spec/spec_helper_acceptance.rb
  94. +1 −1 spec/support/plugin.rb
  95. +17 −4 spec/unit/foreman_resource_rest_v3_spec.rb
  96. +95 −0 spec/unit/provider/foreman_global_parameter/rest_v3_spec.rb
  97. +104 −0 spec/unit/type/foreman_global_parameter_spec.rb
  98. +36 −0 templates/database.yml.epp
  99. +0 −33 templates/database.yml.erb
  100. +1 −0 templates/foreman.socket-overrides.erb
  101. +0 −4 templates/remote_execution_cockpit_session.yml.erb
2 changes: 0 additions & 2 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ Gemfile:
spec/spec_helper.rb:
requires:
- webmock/rspec
spec/spec_helper_acceptance.rb:
locale_workaround: true
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Changelog

## [21.0.0](https://github.com/theforeman/puppet-foreman/tree/21.0.0) (2022-08-04)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/20.2.0...21.0.0)

**Breaking changes:**

- remove support for Debian 10 buster [\#1068](https://github.com/theforeman/puppet-foreman/pull/1068) ([evgeni](https://github.com/evgeni))
- Stop accepting UNSET as a value and rewrite db.yml to EPP [\#1066](https://github.com/theforeman/puppet-foreman/pull/1066) ([ekohl](https://github.com/ekohl))
- Drop EL7 support [\#1061](https://github.com/theforeman/puppet-foreman/pull/1061) ([ehelms](https://github.com/ehelms))
- Fixes [\#34977](https://projects.theforeman.org/issues/34977): Drop apipie\_dsl:cache generation [\#1056](https://github.com/theforeman/puppet-foreman/pull/1056) ([ehelms](https://github.com/ehelms))

**Implemented enhancements:**

- Use Integer type for vhost ssl\_verify\_depth [\#1071](https://github.com/theforeman/puppet-foreman/pull/1071) ([wbclark](https://github.com/wbclark))
- Update to voxpupuli-test 5 [\#1063](https://github.com/theforeman/puppet-foreman/pull/1063) ([ekohl](https://github.com/ekohl))
- Add foreman plugin for netbox [\#1060](https://github.com/theforeman/puppet-foreman/pull/1060) ([dgoetz](https://github.com/dgoetz))
- Add foreman plugin for git\_templates [\#1059](https://github.com/theforeman/puppet-foreman/pull/1059) ([dgoetz](https://github.com/dgoetz))
- Add foreman plugin for vault [\#1058](https://github.com/theforeman/puppet-foreman/pull/1058) ([dgoetz](https://github.com/dgoetz))
- Add foreman plugin for scc\_manager [\#1057](https://github.com/theforeman/puppet-foreman/pull/1057) ([dgoetz](https://github.com/dgoetz))
- Replace template with to\_symbolized\_yaml function [\#1017](https://github.com/theforeman/puppet-foreman/pull/1017) ([ekohl](https://github.com/ekohl))
- Move static parameters to init.pp [\#978](https://github.com/theforeman/puppet-foreman/pull/978) ([ekohl](https://github.com/ekohl))

**Fixed bugs:**

- Fixes [\#35089](https://projects.theforeman.org/issues/35089) - set NoDelay=false when deploying a UNIX socket [\#1062](https://github.com/theforeman/puppet-foreman/pull/1062) ([evgeni](https://github.com/evgeni))

## [20.2.0](https://github.com/theforeman/puppet-foreman/tree/20.2.0) (2022-06-21)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/20.1.0...20.2.0)

**Implemented enhancements:**

- add foreman\_global\_parameter type [\#1054](https://github.com/theforeman/puppet-foreman/pull/1054) ([jhoblitt](https://github.com/jhoblitt))
- derive base\_url from foreman-proxy/settings.yml by default [\#1053](https://github.com/theforeman/puppet-foreman/pull/1053) ([jhoblitt](https://github.com/jhoblitt))

## [20.1.0](https://github.com/theforeman/puppet-foreman/tree/20.1.0) (2022-05-24)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/20.0.0...20.1.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem 'puppet-lint-param-docs', '>= 1.3.0', {"groups"=>["test"]}
gem 'puppet-lint-spaceship_operator_without_tag-check', {"groups"=>["test"]}
gem 'puppet-lint-strict_indent-check', {"groups"=>["test"]}
gem 'puppet-lint-undef_in_function-check', {"groups"=>["test"]}
gem 'voxpupuli-test', '~> 1.4', {"groups"=>["test"]}
gem 'voxpupuli-test', '~> 5.0', {"groups"=>["test"]}
gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]}
gem 'puppet_metadata', '~> 1.3'
gem 'puppet-blacksmith', '>= 6.0.0', {"groups"=>["development"]}
Expand Down
71 changes: 71 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
# Changelog

## [20.2.0](https://github.com/theforeman/puppet-foreman/tree/20.2.0) (2022-06-21)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/20.1.0...20.2.0)

**Implemented enhancements:**

- add foreman\_global\_parameter type [\#1054](https://github.com/theforeman/puppet-foreman/pull/1054) ([jhoblitt](https://github.com/jhoblitt))
- derive base\_url from foreman-proxy/settings.yml by default [\#1053](https://github.com/theforeman/puppet-foreman/pull/1053) ([jhoblitt](https://github.com/jhoblitt))

## [20.1.0](https://github.com/theforeman/puppet-foreman/tree/20.1.0) (2022-05-24)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/20.0.0...20.1.0)

**Implemented enhancements:**

- use instance debug instead of Puppet.debug [\#1052](https://github.com/theforeman/puppet-foreman/pull/1052) ([jhoblitt](https://github.com/jhoblitt))
- Fixes [\#34943](https://projects.theforeman.org/issues/34943): Allow configuration of additional cockpit origins [\#1051](https://github.com/theforeman/puppet-foreman/pull/1051) ([ehelms](https://github.com/ehelms))
- Fixes [\#34602](https://projects.theforeman.org/issues/34602) - restart services after plugin installation [\#1046](https://github.com/theforeman/puppet-foreman/pull/1046) ([evgeni](https://github.com/evgeni))

## [20.0.0](https://github.com/theforeman/puppet-foreman/tree/20.0.0) (2022-04-29)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/19.3.0...20.0.0)

**Breaking changes:**

- Fixes [\#34640](https://projects.theforeman.org/issues/34640) - Drop apipie:cache:index [\#1042](https://github.com/theforeman/puppet-foreman/pull/1042) ([ehelms](https://github.com/ehelms))

**Implemented enhancements:**

- Add Foreman Google plugin [\#1040](https://github.com/theforeman/puppet-foreman/pull/1040) ([stejskalleos](https://github.com/stejskalleos))

**Fixed bugs:**

- Fixes [\#34824](https://projects.theforeman.org/issues/34824) - properly restart foreman when puma config changed [\#1045](https://github.com/theforeman/puppet-foreman/pull/1045) ([evgeni](https://github.com/evgeni))

## [19.3.0](https://github.com/theforeman/puppet-foreman/tree/19.3.0) (2022-04-08)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/19.2.1...19.3.0)

**Implemented enhancements:**

- Include apache::mod::env [\#1038](https://github.com/theforeman/puppet-foreman/pull/1038) ([wbclark](https://github.com/wbclark))
- Allow puppetlabs/postgresql 8.x [\#1031](https://github.com/theforeman/puppet-foreman/pull/1031) ([ekohl](https://github.com/ekohl))
- Refs [\#34505](https://projects.theforeman.org/issues/34505) - Add hammer plugin for foreman\_host\_reports [\#1030](https://github.com/theforeman/puppet-foreman/pull/1030) ([ofedoren](https://github.com/ofedoren))

**Fixed bugs:**

- metadata.json: Use https URL to git repo [\#1036](https://github.com/theforeman/puppet-foreman/pull/1036) ([bastelfreak](https://github.com/bastelfreak))
- Use the new GPG key for Debian packages [\#1034](https://github.com/theforeman/puppet-foreman/pull/1034) ([ekohl](https://github.com/ekohl))

## [19.2.1](https://github.com/theforeman/puppet-foreman/tree/19.2.1) (2022-02-21)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/19.2.0...19.2.1)

**Fixed bugs:**

- Refs [\#34394](https://projects.theforeman.org/issues/34394) - trigger dynflow restart when DB restarts [\#1028](https://github.com/theforeman/puppet-foreman/pull/1028) ([evgeni](https://github.com/evgeni))

## [19.2.0](https://github.com/theforeman/puppet-foreman/tree/19.2.0) (2022-02-04)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/19.1.1...19.2.0)

**Implemented enhancements:**

- puppet/extlib: Allow 6.x [\#1027](https://github.com/theforeman/puppet-foreman/pull/1027) ([bastelfreak](https://github.com/bastelfreak))
- Reflect Foreman 3.2+ support for Debian 11 [\#1025](https://github.com/theforeman/puppet-foreman/pull/1025) ([ekohl](https://github.com/ekohl))
- Explicitly enable the foreman dnf module on Foreman 3.2+ [\#1023](https://github.com/theforeman/puppet-foreman/pull/1023) ([evgeni](https://github.com/evgeni))
- Introduce foreman::settings\_fragment [\#1016](https://github.com/theforeman/puppet-foreman/pull/1016) ([ekohl](https://github.com/ekohl))

## [19.1.1](https://github.com/theforeman/puppet-foreman/tree/19.1.1) (2022-01-26)

[Full Changelog](https://github.com/theforeman/puppet-foreman/compare/19.1.0...19.1.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ previous stable release.
### Foreman version compatibility notes

This module targets Foreman 3.1+.
The module can be used with Foreman 2.4+ by setting `register_in_foreman => false`.
The module can not be used to manage Foreman installations on EL7.

## Types and providers

Expand Down
137 changes: 137 additions & 0 deletions lib/puppet/provider/foreman_global_parameter/rest_v3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# frozen_string_literal: true

Puppet::Type.type(:foreman_global_parameter)
.provide(
:rest_v3,
parent: Puppet::Type.type(:foreman_resource).provider(:rest_v3)
) do
confine feature: %i[json oauth]

mk_resource_methods

# Note that #request is an instance method and as such prevents
# self.instances and self.prefetch from being implimented.

# The foreman api has both `hidden_value` and `hidden_value?` fields. The
# later is the boolean value.
def hidden_value
@property_hash[:hidden_value?]
end

def hidden_value=(value)
@property_hash[:hidden_value?] = value
end

def create
@property_hash[:ensure] = :present
end

def exists?
get_common_parameter!
@property_hash[:ensure] == :present
end

def destroy
@property_hash[:ensure] = :absent
end

def flush
case self.ensure
when :present
# if there is already an id, this is an update
if id.nil?
create_common_parameter
else
update_common_parameter
end
when :absent
destroy_common_parameter
else
raise Puppet::Error, "invalid :ensure value: #{self.ensure}"
end
end

private

def id
@property_hash[:id]
end

def base_path
'api/v2/common_parameters'
end

def get_common_parameter!
path = base_path
params = {
search: "name=#{resource[:name]}",
show_hidden: true
}
r = request(:get, base_path, params)

raise Puppet::Error, "Error making GET request to Foreman at #{request_uri(path)}: #{error_message(r)}" unless success?(r)

begin
results = JSON.parse(r.body)['results'].first
rescue JSON::ParserError
raise Puppet::Error, "unable to parse as JSON: #{r.body}"
end

if results.nil?
@property_hash[:ensure] = :absent
else
@property_hash = results.transform_keys(&:to_sym).transform_values do |v|
resource.munge_boolean_to_symbol(v)
end
@property_hash[:ensure] = :present
end
end

def create_common_parameter
path = base_path
data = {
common_parameter: {
name: resource[:name],
value: resource[:value],
parameter_type: resource[:parameter_type]
}
}
data[:hidden_value] = resource[:hidden_value] unless resource[:hidden_value].nil?
data.transform_values! { |v| resource.munge_symbol_to_boolean(v) }
r = request(:post, path, {}, data.to_json)

return if success?(r)

raise Puppet::Error, "Error making POST request to Foreman at #{request_uri(path)}: #{error_message(r)}"
end

def update_common_parameter
path = "#{base_path}/#{id}"
data = {
common_parameter: {
name: resource[:name],
value: resource[:value],
parameter_type: resource[:parameter_type]
}
}
data[:hidden_value] = resource[:hidden_value] unless resource[:hidden_value].nil?
data.transform_values! { |v| resource.munge_symbol_to_boolean(v) }
r = request(:put, path, {}, data.to_json)

return if success?(r)

raise Puppet::Error, "Error making PUT request to Foreman at #{request_uri(path)}: #{error_message(r)}"
end

def destroy_common_parameter
path = "#{base_path}/#{id}"
r = request(:delete, path)

unless success?(r)
error_string = "Error making DELETE request to Foreman at #{request_uri(path)}: #{error_message(r)}"
raise Puppet::Error, error_string
end

@property_hash.clear
end
end
20 changes: 17 additions & 3 deletions lib/puppet/provider/foreman_resource/rest_v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,23 @@ def oauth_consumer_secret
end
end

def foreman_url
@foreman_url ||= begin
if resource[:base_url]
resource[:base_url]
else
begin
YAML.load_file('/etc/foreman-proxy/settings.yml')[:foreman_url]
rescue
fail "Resource #{resource[:name]} cannot be managed: No base_url available"
end
end
end
end

def oauth_consumer
@consumer ||= OAuth::Consumer.new(oauth_consumer_key, oauth_consumer_secret, {
:site => resource[:base_url],
:site => foreman_url,
:request_token_path => '',
:authorize_path => '',
:access_token_path => '',
Expand All @@ -56,7 +70,7 @@ def generate_token
end

def request_uri(path)
base_url = resource[:base_url]
base_url = foreman_url
base_url += '/' unless base_url.end_with?('/')
URI.join(base_url, path)
end
Expand Down Expand Up @@ -99,7 +113,7 @@ def success?(response)
end

def error_message(response)
fqdn = URI::parse(resource[:base_url]).host
fqdn = URI::parse(foreman_url).host

explanations = {
'400' => "Something is wrong with the data sent to Foreman at #{fqdn}",
Expand Down
65 changes: 65 additions & 0 deletions lib/puppet/type/foreman_global_parameter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true

require_relative '../../puppet_x/foreman/common'

Puppet::Type.newtype(:foreman_global_parameter) do
desc 'foreman_global_parameter Manipulate global parameters'

instance_eval(&PuppetX::Foreman::Common::REST_API_COMMON_PARAMS)

newparam(:name, namevar: true) do
desc 'Parameter name'
end

newproperty(:parameter_type) do
desc 'Type of the parameter'

munge { |v| v.to_s }
end

newproperty(:value) do
desc 'Parameter value'

munge { |v| @resource.munge_boolean_to_symbol(v) }
end

newproperty(:hidden_value) do
desc 'Should the value be hidden'

munge { |v| @resource.munge_boolean_to_symbol(v) }

validate do |v|
unless [TrueClass, FalseClass].include?(v.class)
raise Puppet::ResourceError, 'hidden_value expected a boolean value.'
end
end
end

# Convert booleans into symbols to work around parameter/property handling of
# booleans being broken.
#
# See:
# https://tickets.puppetlabs.com/browse/PUP-2368
# https://tickets.puppetlabs.com/browse/PUP-8442
def munge_boolean_to_symbol(value)
case value
when TrueClass
:true
when FalseClass
:false
else
value
end
end

def munge_symbol_to_boolean(value)
case value
when :true
true
when :false
false
else
value
end
end
end
Loading