Showing with 45 additions and 2 deletions.
  1. +8 −0 CHANGELOG.md
  2. +10 −1 manifests/plugin/ansible.pp
  3. +1 −1 metadata.json
  4. +17 −0 spec/classes/plugin_ansible_spec.rb
  5. +9 −0 templates/settings-ansible.py.epp
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [8.5.0](https://github.com/theforeman/puppet-pulpcore/tree/8.5.0) (2023-09-18)

[Full Changelog](https://github.com/theforeman/puppet-pulpcore/compare/8.4.0...8.5.0)

**Implemented enhancements:**

- Refs [\#36709](https://projects.theforeman.org/issues/36709) - Expose ANSIBLE\_PERMISSION\_CLASSES setting [\#304](https://github.com/theforeman/puppet-pulpcore/pull/304) ([ekohl](https://github.com/ekohl))

## [8.4.0](https://github.com/theforeman/puppet-pulpcore/tree/8.4.0) (2023-08-22)

[Full Changelog](https://github.com/theforeman/puppet-pulpcore/compare/8.3.0...8.4.0)
Expand Down
11 changes: 10 additions & 1 deletion manifests/plugin/ansible.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
# @param ansible_galaxy_path
# In the Apache configuration the path to forward to the api app
# for ansible galaxy support
# @param permission_classes
# Configure the RBAC permission classes
class pulpcore::plugin::ansible (
String $ansible_galaxy_path = '/pulp_ansible/galaxy/',
Optional[Array[String[1]]] $permission_classes = undef,
) {
$context = {
'directories' => [],
Expand All @@ -25,8 +28,14 @@
$external_api_url = "https://${pulpcore::servername}"
}

$config_context = {
'external_api_url' => $external_api_url,
'external_content_url' => $external_content_url,
'permission_classes' => $permission_classes,
}

pulpcore::plugin { 'ansible':
config => "ANSIBLE_API_HOSTNAME = \"${external_api_url}\"\nANSIBLE_CONTENT_HOSTNAME = \"${external_content_url}\"",
config => epp('pulpcore/settings-ansible.py.epp', $config_context),
https_content => epp('pulpcore/apache-fragment.epp', $context),
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theforeman-pulpcore",
"version": "8.4.0",
"version": "8.5.0",
"author": "theforeman",
"summary": "Installs next generation Pulp server",
"license": "GPL-3.0-or-later",
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/plugin_ansible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@
is_expected.to contain_concat__fragment('plugin-ansible')
.with_content(%r{^ANSIBLE_API_HOSTNAME = "https://foo.example.com"})
.with_content(%r{^ANSIBLE_CONTENT_HOSTNAME = "https://foo.example.com/pulp/content"})
.without_content(/ANSIBLE_PERMISSION_CLASSES/)
end

context 'with permission classes' do
context 'set to an empty array' do
let(:params) { { permission_classes: [] } }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_concat__fragment('plugin-ansible').with_content(/^ANSIBLE_PERMISSION_CLASSES = \[\]$/) }
end

context 'set to a value' do
let(:params) { { permission_classes: ['foo', 'bar'] } }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_concat__fragment('plugin-ansible').with_content(/^ANSIBLE_PERMISSION_CLASSES = \["foo", "bar"\]$/) }
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions templates/settings-ansible.py.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% | Stdlib::Httpurl $external_api_url,
Stdlib::Httpurl $external_content_url,
Optional[Array[String[1]]] $permission_classes,
| -%>
ANSIBLE_API_HOSTNAME = "<%= $external_api_url %>"
ANSIBLE_CONTENT_HOSTNAME = "<%= $external_content_url %>"
<% if $permission_classes { -%>
ANSIBLE_PERMISSION_CLASSES = <%= to_python($permission_classes) %>
<% } -%>