Skip to content

Commit

Permalink
Manage the static assets via a class
Browse files Browse the repository at this point in the history
Since 8c66bff the pulpcore-manager
command runs as root. On a fresh installation this is fine, but on
upgrades the user doesn't own /var/lib/pulp/assets. This explicitly
manages the static root.

It is split off to a separate class to better capture the dependencies.
The database doesn't need to refresh due to static files, nor any
services.
  • Loading branch information
ekohl committed Sep 14, 2020
1 parent 8e71bbb commit 7c2e666
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
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::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::static_root],
}
}
6 changes: 5 additions & 1 deletion 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

0 comments on commit 7c2e666

Please sign in to comment.