puppet-nova/manifests/cell_v2/map_instances.pp
Diana Clarke e128ba6538 Correct permissions on the nova logfiles
When you execute nova-manage commands, oslo logs to the following
location (file name is dynamically created based on command name).

    /var/log/nova/nova-manage.log

Because puppet-nova is executing these commands as root,
nova-manage.log is owned by root, preventing the 'nova-manage
db archive_deleted_rows' entry in nova's crontab from executing.

    Permission denied: '/var/log/nova/nova-manage.log'

This log file is also an outlier, as all other log files in
/var/log/nova/ are owned by nova:nova.

Similar issues are possible for other nova logs, if for example
a nova services is initially started manually as root, so the
ownership of all nova logs is corrected before configuring nova.

Co-Authored-By: Oliver Walsh <owalsh@redhat.com>
Co-Authored-By: Diana Clarke <diana.joan.clarke@gmail.com>
Co-Authored-By: Maciej Kucia <maciej@kucia.net>
Closes-Bug: #1671681
Change-Id: I0ca0110cbf9139c79074cf603dcab9135f96e765
2017-12-19 20:24:52 +00:00

50 lines
1.5 KiB
Puppet

# == Class: nova::cell_v2::map_instances
#
# Resource to run the map_instances action for cell v2
#
# === Parameters
#
# [*cell_uuid*]
# (String) Cell UUID to map unmigrated instances to. It is recommended to use
# this rather than cell name. Either cell_uuid or cell_name must be provided.
# Defaults to undef.
#
# [*cell_name*]
# (String) Cell name to map the unmigrated instances to. We will attempt to
# extract the cell uuid using the name as the command requires a cell uuid.
# NOTE: This will not work if you have multiple cells with the same name.
# Defaults to undef.
#
# [*extra_params*]
# (String) Extra parameters to pass to the nova-manage commands.
# Defaults to ''.
#
class nova::cell_v2::map_instances (
$cell_uuid = undef,
$cell_name = undef,
$extra_params = '',
) {
include ::nova::deps
include ::nova::params
if (!$cell_uuid and !$cell_name) {
fail('Either cell_uuid or cell_name must be provided')
}
if ($cell_uuid) {
$cell_uuid_real = $cell_uuid
} else {
# NOTE(aschultz): This is what breaks if you have multiple cells with the
# same name. So that's why using cell_uuid is better.
$cell_uuid_real = "$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '\$d' | awk -F ' *| *' '\$2 == \"${cell_name}\" {print \$4}')"
}
exec { 'nova-cell_v2-map_instances':
path => ['/bin', '/usr/bin'],
command => "nova-manage ${extra_params} cell_v2 map_instances --cell_uuid=${cell_uuid_real}",
user => $::nova::params::nova_user,
refreshonly => true,
}
}