Puppet Class: profile::openstack::eqiad1::nova::instance_purge

Defined in:
modules/profile/manifests/openstack/eqiad1/nova/instance_purge.pp

Overview

Parameters:

  • openstack_controllers (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::openstack::eqiad1::openstack_controllers'))
  • purge_projects (Array[Hash]) (defaults to: lookup('profile::openstack::eqiad1::purge_projects'))


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'modules/profile/manifests/openstack/eqiad1/nova/instance_purge.pp', line 1

class profile::openstack::eqiad1::nova::instance_purge(
    Array[Stdlib::Fqdn] $openstack_controllers = lookup('profile::openstack::eqiad1::openstack_controllers'),
    Array[Hash]         $purge_projects        = lookup('profile::openstack::eqiad1::purge_projects'),
    ) {


    # systemd::timer::job does not take a boolean
    if ($::fqdn == $openstack_controllers[0]) {
        $ensure = 'present'
    }
    else {
        $ensure = 'absent'
    }

    # We only want this running in one place; just pick the first
    #  option in the list.
    $purge_projects.each |Hash $purge_rules| {
        systemd::timer::job { "purge_project_instances_${purge_rules['project']}":
            ensure                    => $ensure,
            description               => "Delete VMs older than ${purge_rules['days_to_delete']} days",
            interval                  => {
                'start'    => 'OnCalendar',
                'interval' => '*-*-* 14:00:00', # Daily at 14:00 UTC
            },
            command                   => "/usr/local/sbin/wmcs-instancepurge --project ${purge_rules['project']} --days-to-delete ${purge_rules['days_to_delete']} --days-to-nag ${purge_rules['days_to_nag']}",
            logging_enabled           => false,
            monitoring_enabled        => true,
            monitoring_contact_groups => 'wmcs-team',
            user                      => 'root',
            require                   => File['/usr/local/sbin/wmcs-instancepurge'],
        }
    }
}