Puppet Class: openstack::glance::image_sync

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

Overview

Parameters:

  • active (Any)
  • version (Any)
  • glance_image_dir (Any)
  • nova_controller_standby (Any) (defaults to: '')


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
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
# File 'modules/openstack/manifests/glance/image_sync.pp', line 1

class openstack::glance::image_sync(
    $active,
    $version,
    $glance_image_dir,
    $nova_controller_standby='',
) {

    require openstack::glance::service

    # Cron doesn't take a bool
    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 $active and !empty($nova_controller_standby) {
        cron { 'rsync_glance_images':
            ensure  => $ensure,
            command => "/usr/bin/rsync --delete --delete-after -aSO ${glance_image_dir}/ ${nova_controller_standby}:${glance_image_dir}/",
            minute  => 15,
            user    => 'glancesync',
            require => User['glancesync'],
        }
    }

    # If we are not the active server and are definitely
    # the standby then setup the permissions insurance
    # XXX: what is this for?
    if !($active) {

        if ($::fqdn == $nova_controller_standby) {
            $chown_ensure = 'present'
        }
        else {
            $chown_ensure = 'absent'
        }

        cron { 'rsync_chown_images':
            ensure  => $chown_ensure,
            command => "chown -R glance ${glance_image_dir}/*",
            minute  => 30,
            user    => 'root',
        }
    }
}