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

Manage the static assets via a class #121

Merged
merged 2 commits into from
Sep 14, 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
5 changes: 0 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
mode => '0775',
}

pulpcore::admin { 'collectstatic --noinput':
refreshonly => true,
subscribe => Concat['pulpcore settings'],
}

selinux::port { 'pulpcore-api-port':
ensure => 'present',
seltype => 'pulpcore_port_t',
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@
Optional[String] $remote_user_environ_name = undef,
Integer[0] $worker_count = min(8, $facts['processors']['count']),
) {

$settings_file = "${config_dir}/settings.py"

contain pulpcore::install
contain pulpcore::database
contain pulpcore::config
contain pulpcore::static
contain pulpcore::service
contain pulpcore::apache

Class['pulpcore::install'] ~> Class['pulpcore::config', 'pulpcore::database', 'pulpcore::service']
Class['pulpcore::config'] ~> Class['pulpcore::database', 'pulpcore::service']
Class['pulpcore::database'] -> Class['pulpcore::service'] -> Class['pulpcore::apache']
Class['pulpcore::config'] ~> Class['pulpcore::database', 'pulpcore::static', 'pulpcore::service']
Class['pulpcore::database', 'pulpcore::static'] -> Class['pulpcore::service'] -> Class['pulpcore::apache']

# lint:ignore:spaceship_operator_without_tag
Class['pulpcore::install']
Expand Down
16 changes: 16 additions & 0 deletions manifests/static.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# @summary Manage the static files (assets)
# @api private
class pulpcore::static {
file { $pulpcore::pulp_static_root:
ensure => directory,
owner => $pulpcore::user,
group => $pulpcore::group,
mode => '0755',
}

pulpcore::admin { 'collectstatic --noinput':
refreshonly => true,
subscribe => Concat['pulpcore settings'],
require => File[$pulpcore::pulp_static_root],
}
}
8 changes: 6 additions & 2 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
is_expected.to contain_file('/var/lib/pulp')
is_expected.to contain_file('/var/lib/pulp/docroot')
is_expected.to contain_file('/var/lib/pulp/tmp')
is_expected.to contain_pulpcore__admin('collectstatic --noinput')
end

it 'sets up static files' do
is_expected.to contain_file('/var/lib/pulp/assets')
is_expected.to contain_pulpcore__admin('collectstatic --noinput')
is_expected.to contain_exec('pulpcore-manager collectstatic --noinput')
end

it 'configures the database' do
is_expected.to contain_class('pulpcore::database')
Expand Down Expand Up @@ -250,11 +254,11 @@
is_expected.to compile.with_all_deps
is_expected.to contain_file('/my/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')
.with_docroot('/my/custom/directory')
is_expected.to contain_concat__fragment('base')
.with_content(%r{MEDIA_ROOT = "/my/custom/directory"})
.with_content(%r{STATIC_ROOT = "/my/other/custom/directory"})
end
end
end
Expand Down
1 change: 0 additions & 1 deletion templates/pulpcore-api.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Wants=network-online.target
[Service]
Environment="DJANGO_SETTINGS_MODULE=pulpcore.app.settings"
Environment="PULP_SETTINGS=<%= scope['pulpcore::settings_file'] %>"
Environment="PULP_STATIC_ROOT=<%= scope['pulpcore::pulp_static_root'] %>"
User=<%= scope['pulpcore::user'] %>
PIDFile=/run/pulpcore-api.pid
RuntimeDirectory=pulpcore-api
Expand Down
1 change: 1 addition & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DATABASES = {
},
}
MEDIA_ROOT = "<%= scope['pulpcore::webserver_static_dir'] %>"
STATIC_ROOT = "<%= scope['pulpcore::pulp_static_root'] %>"
REDIS_HOST = "localhost"
REDIS_PORT = "<%= scope['redis::port'] %>"
REDIS_DB = <%= scope['pulpcore::redis_db'] %>
Expand Down