Skip to content

Commit

Permalink
Merge pull request #136 from tedgarb/add_hiera_subscriptions
Browse files Browse the repository at this point in the history
Allow subscriptions to be attached via hiera
  • Loading branch information
bastelfreak authored Dec 19, 2023
2 parents c68e560 + 14e7c93 commit 4656af6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The following parameters are available in the `rhsm` class:
* [`no_proxy`](#-rhsm--no_proxy)
* [`baseurl`](#-rhsm--baseurl)
* [`package_ensure`](#-rhsm--package_ensure)
* [`enabled_subscription_ids`](#-rhsm--enabled_subscription_ids)
* [`enabled_repo_ids`](#-rhsm--enabled_repo_ids)
* [`server_timeout`](#-rhsm--server_timeout)
* [`inotify`](#-rhsm--inotify)
Expand Down Expand Up @@ -246,6 +247,14 @@ Whether to install subscription-manager, directly passed to the `ensure` param o

Default value: `'installed'`

##### <a name="-rhsm--enabled_subscription_ids"></a>`enabled_subscription_ids`

Data type: `Array[String[1]]`

A listing of subscription IDs to provide to the subscription-manager attach --pool command.

Default value: `[]`

##### <a name="-rhsm--enabled_repo_ids"></a>`enabled_repo_ids`

Data type: `Array[String[1]]`
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# @param no_proxy no_proxy definition
# @param baseurl Base URL for rhsm, default provided
# @param package_ensure Whether to install subscription-manager, directly passed to the `ensure` param of the package.
# @param enabled_subscription_ids A listing of subscription IDs to provide to the subscription-manager attach --pool command.
# @param enabled_repo_ids A listing of the Repo IDs to provide to the subscription-manager repo --enable command.
# @param server_timeout HTTP timeout in seconds
# @param inotify Inotify is used for monitoring changes in directories with certificates. When this directory is mounted using a network
Expand Down Expand Up @@ -85,6 +86,7 @@
Integer[0,1] $manage_repos = 1,
Integer[0,1] $full_refresh_on_yum = 0,
String[1] $package_ensure = 'installed',
Array[String[1]] $enabled_subscription_ids = [],
Array[String[1]] $enabled_repo_ids = [],
Integer[0,1] $inotify = 1,
Integer[0] $server_timeout = 180,
Expand Down Expand Up @@ -180,6 +182,10 @@
}
}

rh_subscription { $enabled_subscription_ids:
ensure => present,
}

rh_repo { $enabled_repo_ids:
ensure => present,
}
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@
it { is_expected.to contain_rh_repo('rhel-7-server-optional-rpms') }
end

context 'with list of subscriptions to enable' do
let(:params) do
{
rh_password: 'password',
rh_user: 'username',
enabled_subscription_ids: %w[
001234567890
00123456789a
]
}
end

it { is_expected.to have_rh_subscription_resource_count(2) }

it { is_expected.to contain_rh_subscription('001234567890') }
it { is_expected.to contain_rh_subscription('00123456789a') }
end

context 'with proxy scheme set to https' do
let(:params) do
{
Expand Down

0 comments on commit 4656af6

Please sign in to comment.