Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pulpcore-manager #111

Merged
merged 2 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions manifests/admin.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @summary Run a python3-django-admin command
# @summary Run a pulpcore-manager command
#
# @param command
# The command to run
Expand All @@ -14,10 +14,10 @@
# @param path
# The path to look for commands.
#
# @param pulp_settings
# The pulp settings file to use
# @param user
# The user to execute the command.
#
# @param static_root
# @param pulp_settings
# Root directory for static content
#
# @see exec
Expand All @@ -26,17 +26,14 @@
Boolean $refreshonly = false,
Optional[String] $unless = undef,
Array[Stdlib::Absolutepath] $path = ['/usr/bin'],
String $user = $pulpcore::user,
Stdlib::Absolutepath $pulp_settings = $pulpcore::settings_file,
Stdlib::Absolutepath $static_root = $pulpcore::pulp_static_root,
) {
Concat <| title == 'pulpcore settings' |>
-> exec { "python3-django-admin ${command}":
-> exec { "pulpcore-manager ${command}":
user => $user,
path => $path,
environment => [
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings',
"PULP_SETTINGS=${pulp_settings}",
"PULP_STATIC_ROOT=${static_root}",
],
environment => ["PULP_SETTINGS=${pulp_settings}"],
refreshonly => $refreshonly,
unless => $unless,
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
}

pulpcore::admin { 'migrate --noinput':
unless => 'python3-django-admin migrate --plan | grep "No planned migration operations"',
unless => 'pulpcore-manager migrate --plan | grep "No planned migration operations"',
refreshonly => false,
}

pulpcore::admin { 'reset-admin-password --random':
unless => 'python3-django-admin dumpdata auth.User | grep "auth.user"',
unless => 'pulpcore-manager dumpdata auth.User | grep "auth.user"',
refreshonly => false,
require => Pulpcore::Admin['migrate --noinput'],
}
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class { 'pulpcore':
its(:exit_status) { is_expected.to eq 0 }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py python3-django-admin dumpdata auth.User") do
describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager dumpdata auth.User") do
its(:stdout) { is_expected.to match(/auth\.user/) }
its(:exit_status) { is_expected.to eq 0 }
end
Expand Down
10 changes: 2 additions & 8 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
is_expected.to contain_class('postgresql::server')
is_expected.to contain_postgresql__server__db('pulpcore')
is_expected.to contain_pulpcore__admin('migrate --noinput')
is_expected.to contain_exec('python3-django-admin migrate --noinput')
is_expected.to contain_exec('pulpcore-manager migrate --noinput')
is_expected.to contain_pulpcore__admin('reset-admin-password --random')
is_expected.to contain_exec('python3-django-admin reset-admin-password --random')
is_expected.to contain_exec('pulpcore-manager reset-admin-password --random')
end

it 'configures apache' do
Expand Down Expand Up @@ -249,12 +249,6 @@
it do
is_expected.to compile.with_all_deps
is_expected.to contain_file('/my/custom/directory')
is_expected.to contain_exec('python3-django-admin collectstatic --noinput')
.with_environment([
"DJANGO_SETTINGS_MODULE=pulpcore.app.settings",
"PULP_SETTINGS=/etc/pulp/settings.py",
"PULP_STATIC_ROOT=/my/other/custom/directory"
])
is_expected.to contain_systemd__unit_file('pulpcore-api.service')
.with_content(%r{Environment="PULP_STATIC_ROOT=/my/other/custom/directory"})
is_expected.to contain_apache__vhost('pulpcore')
Expand Down
32 changes: 11 additions & 21 deletions spec/defines/admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@
let(:facts) { os_facts }
let(:title) { 'help' }

context 'with a fixed pulp_settings and static_root' do
context 'with a fixed pulp_settings and user' do
let(:params) do
{
pulp_settings: '/etc/pulpcore/settings.py',
static_root: '/var/lib/pulp/assets',
user: 'pulpcore',
}
end

context 'default parameters' do
it do
is_expected.to compile.with_all_deps
is_expected.to contain_exec('python3-django-admin help')
.with_environment([
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings',
'PULP_SETTINGS=/etc/pulpcore/settings.py',
'PULP_STATIC_ROOT=/var/lib/pulp/assets',
])
is_expected.to contain_exec('pulpcore-manager help')
.with_user('pulpcore')
.with_environment(['PULP_SETTINGS=/etc/pulpcore/settings.py'])
.with_refreshonly(false)
.with_unless(nil)
end
Expand All @@ -34,18 +31,14 @@
command: 'migrate --noinput',
refreshonly: true,
unless: '/usr/bin/false',
static_root: '/var/lib/pulp/assets',
)
end

it do
is_expected.to compile.with_all_deps
is_expected.to contain_exec('python3-django-admin migrate --noinput')
.with_environment([
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings',
'PULP_SETTINGS=/etc/pulpcore/settings.py',
'PULP_STATIC_ROOT=/var/lib/pulp/assets',
])
is_expected.to contain_exec('pulpcore-manager migrate --noinput')
.with_user('pulpcore')
.with_environment(['PULP_SETTINGS=/etc/pulpcore/settings.py'])
.with_refreshonly(true)
.with_unless('/usr/bin/false')
end
Expand All @@ -60,12 +53,9 @@
is_expected.to compile.with_all_deps
is_expected.to contain_pulpcore__admin('help').with_pulp_settings('/etc/pulp/settings.py')
is_expected.to contain_concat('pulpcore settings')
is_expected.to contain_exec('python3-django-admin help')
.with_environment([
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings',
'PULP_SETTINGS=/etc/pulp/settings.py',
'PULP_STATIC_ROOT=/var/lib/pulp/assets',
])
is_expected.to contain_exec('pulpcore-manager help')
.with_user('pulp')
.with_environment(['PULP_SETTINGS=/etc/pulp/settings.py'])
.with_refreshonly(false)
.with_unless(nil)
.that_requires('Concat[pulpcore settings]')
Expand Down