Puppet Class: labs_bootstrapvz

Defined in:
modules/labs_bootstrapvz/manifests/init.pp

Overview



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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'modules/labs_bootstrapvz/manifests/init.pp', line 1

class labs_bootstrapvz() {

    package { 'nbd-client':
        ensure => 'present',
    }

    # This weird greater-than check is to deal with the fact that
    #  Buster doesn't actually have a release number assigned
    #  until it's released.  We need to remove that clause
    #  sometime between Buster and Bullseye.
    if os_version('debian == buster') or os_version('debian > buster')
    {
        # Until upstream packaging catches up, use our custom
        #  package for this.
        package { 'python-bootstrap-vz':
            ensure => present,
        }
    } else {
        package { 'bootstrap-vz':
            ensure => present,
        }
    }

    package { 'zerofree':
        ensure => present,
    }

    package { 'kpartx':
        ensure => present,
    }

    $bootstrap_filepath = '/etc/bootstrap-vz/'

    file { $bootstrap_filepath:
        ensure => directory,
    }

    file { "${bootstrap_filepath}/manifests":
        ensure  => directory,
        require => File[$bootstrap_filepath],
    }

    file { "${bootstrap_filepath}/firstscripts":
        ensure  => directory,
        require => File[$bootstrap_filepath],
    }

    file { "${bootstrap_filepath}/puppet":
        ensure  => directory,
        require => File[$bootstrap_filepath],
    }

    file { "${bootstrap_filepath}/manifests/labs-jessie.manifest.yaml":
        mode    => '0444',
        source  => 'puppet:///modules/labs_bootstrapvz/labs-jessie.manifest.yaml',
        require => File["${bootstrap_filepath}/manifests"],
    }

    file { "${bootstrap_filepath}/manifests/labs-stretch.manifest.yaml":
        mode    => '0444',
        source  => 'puppet:///modules/labs_bootstrapvz/labs-stretch.manifest.yaml',
        require => File["${bootstrap_filepath}/manifests"],
    }

    file { "${bootstrap_filepath}/manifests/cloud-buster.manifest.yaml":
        mode    => '0444',
        source  => 'puppet:///modules/labs_bootstrapvz/cloud-buster.manifest.yaml',
        require => File["${bootstrap_filepath}/manifests"],
    }

    $projectregex = "s/${::labsproject}/_PROJECT_/g"
    $fqdnregex = "s/${::fqdn}/_FQDN_/g"

    # We can't just use $::servername here because the master
    #  returns cloud-puppetmaster-03 vs. the service name, puppetmaster.cloudinfra.wmflabs.org
    $puppetmaster = hiera('puppetmaster')
    $masterregex = "s/${puppetmaster}/_MASTER_/g"

    Exec { path => '/bin' }

    exec { "cp /etc/security/access.conf ${bootstrap_filepath}/access.conf":
    }

    ~> exec { "sed -i '${projectregex}' ${bootstrap_filepath}/access.conf":
    }

    if os_version('debian < buster') {
        exec { "cp /etc/nslcd.conf ${bootstrap_filepath}/nslcd.conf":
        }

        ~> exec { "sed -i '${projectregex}' ${bootstrap_filepath}/nslcd.conf":
        }
    }

    exec { "cp /etc/ldap/ldap.conf ${bootstrap_filepath}/nss_ldap.conf":
    }

    ~> exec { "sed -i '${projectregex}' ${bootstrap_filepath}/nss_ldap.conf":
    }

    exec { "cp /etc/puppet/puppet.conf ${bootstrap_filepath}/puppet/puppet.conf":
        require => File["${bootstrap_filepath}/puppet"],
    }

    ~> exec { "sed -i '${fqdnregex}' ${bootstrap_filepath}/puppet/puppet.conf":
    }

    ~> exec { "sed -i '${masterregex}' ${bootstrap_filepath}/puppet/puppet.conf":
    }

    exec { "sed -i '${projectregex}' ${bootstrap_filepath}/puppet/puppet.conf":
    }

    # The bootstrap run tends to time out during apt
    ~> apt::conf { 'bootstrap-timeout':
        priority => '99',
        key      => 'Acquire::http::Timeout',
        value    => '3000',
    }
}