Puppet Class: openstack::glance::image_sync

Defined in:
modules/openstack/manifests/glance/image_sync.pp

Overview

openstack::glance::image_sync ==

Transfers Glance images from master to standby server

Parameters ===

active

If these definitions should be present or absent

*glance_image_dir

Directory where Glance stores its uploaded images

nova_controller_standby

Hostname of the standby server

Parameters:

  • active (Boolean)
  • glance_image_dir (String)
  • nova_controller_standby (String) (defaults to: undef)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'modules/openstack/manifests/glance/image_sync.pp', line 13

class openstack::glance::image_sync(
    Boolean $active,
    String $glance_image_dir,
    String $nova_controller_standby = undef,
) {
    require openstack::glance::service

    # systemd::timer::job does not take a boolean
    if $active {
        $ensure = 'present'
    }
    else {
        $ensure = 'absent'
    }

    # Set up a keypair and rsync image files between active and standby
    user { 'glancesync':
        ensure     => 'present',
        name       => 'glancesync',
        shell      => '/bin/sh',
        comment    => 'glance rsync user',
        gid        => 'glance',
        managehome => true,
        require    => Package['glance'],
        system     => true,
    }

    ssh::userkey { 'glancesync':
        ensure  => 'present',
        require => User['glancesync'],
        content => secret('ssh/glancesync/glancesync.pub'),
    }

    file { '/home/glancesync/.ssh':
        ensure  => directory,
        owner   => 'glancesync',
        group   => 'glance',
        mode    => '0700',
        require => User['glancesync'],
    }

    file { '/home/glancesync/.ssh/id_rsa':
        content   => secret('ssh/glancesync/glancesync.key'),
        owner     => 'glancesync',
        group     => 'glance',
        mode      => '0600',
        require   => File['/home/glancesync/.ssh'],
        show_diff => false,
    }

    # If we are the master Glance server, then sync images to the standby
    if $active and $nova_controller_standby {

        # TODO: Remove after change is applied
        cron { 'rsync_glance_images':
            ensure => absent,
            user   => 'glancesync',
        }

        systemd::timer::job { 'glance_rsync_images':
            ensure                    => $ensure,
            description               => 'Copy Glance images to standby server',
            command                   => "/usr/bin/rsync --delete --delete-after -aSO ${glance_image_dir}/ ${nova_controller_standby}:${glance_image_dir}/",
            interval                  => {
            'start'    => 'OnCalendar',
            'interval' => '*-*-* *:15:00', # Every hour at minute 15
            },
            logging_enabled           => false,
            monitoring_enabled        => true,
            monitoring_contact_groups => 'wmcs-team',
            user                      => 'glancesync',
            require                   => User['glancesync'],
        }
    }

    # If we are the standby server, fix file ownership (glancesync->glance)
    if !($active) and ($::fqdn == $nova_controller_standby) {
        file { $glance_image_dir:
            ensure  => directory,
            owner   => 'glance',
            group   => 'glance',
            recurse => true,
        }
    }
}