forked from theforeman/puppet-pulpcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is essentially a wrapper around django-admin with the right settings.
- Loading branch information
Showing
4 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# @summary Run a django-admin command | ||
# | ||
# @param command | ||
# The command to run | ||
# | ||
# @param refreshonly | ||
# The command should only be run as a refresh mechanism for when a dependent | ||
# object is changed. | ||
# | ||
# @param unless | ||
# A test command that checks the state of the target system and restricts | ||
# when the exec can run. | ||
# | ||
# @param path | ||
# The path to look for commands. | ||
# | ||
# @param pulp_settings | ||
# The pulp settings file to use | ||
# | ||
# @see exec | ||
define pulpcore::admin( | ||
String $command = $title, | ||
Boolean $refreshonly = false, | ||
Optional[String] $unless = undef, | ||
Array[Stdlib::Absolutepath] $path = ['/usr/bin'], | ||
Stdlib::Absolutepath $pulp_settings = $pulpcore::settings_file, | ||
) { | ||
File <| title == $pulp_settings |> | ||
-> exec { "django-admin ${title}": | ||
path => $path, | ||
environment => [ | ||
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings', | ||
"PULP_SETTINGS=${pulp_settings}", | ||
], | ||
refreshonly => $refreshonly, | ||
unless => $unless, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'spec_helper' | ||
|
||
describe 'pulpcore::admin' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:title) { 'help' } | ||
|
||
context 'with a fixed pulp_settings' do | ||
let(:params) { { pulp_settings: '/etc/pulpcore/settings.py' } } | ||
|
||
context 'default parameters' do | ||
it do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulpcore/settings.py']) | ||
.with_refreshonly(false) | ||
.with_unless(nil) | ||
end | ||
end | ||
|
||
context 'default parameters' do | ||
let(:params) do | ||
super().merge( | ||
command: 'migrate --noinput', | ||
refreshonly: true, | ||
unless: '/usr/bin/false', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulpcore/settings.py']) | ||
.with_refreshonly(true) | ||
.with_unless('/usr/bin/false') | ||
end | ||
end | ||
end | ||
|
||
context 'with inheritance' do | ||
let(:pre_condition) { 'include pulpcore' } | ||
|
||
context 'default parameters' do | ||
it do | ||
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_file('/etc/pulp/settings.py') | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulp/settings.py']) | ||
.with_refreshonly(false) | ||
.with_unless(nil) | ||
.that_requires('File[/etc/pulp/settings.py]') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |