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
# File 'modules/labs_bootstrapvz/manifests/init.pp', line 1

class labs_bootstrapvz() {

    $python_package = debian::codename::lt('buster') ? {
        true    => 'bootstrap-vz',
        default => 'python-bootstrap-vz',
    }

    ensure_packages(['nbd-client', 'zerofree', 'kpartx', $python_package])

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

    ['', 'manifests', 'firstscript', 'puppet'].each |$subdir| {
        file {"${bootstrap_filepath}/${subdir}":
            ensure => directory,
        }
    }

    file {
        default:
            mode    => '0444';
        "${bootstrap_filepath}/manifests/labs-stretch.manifest.yaml":
            source  => 'puppet:///modules/labs_bootstrapvz/labs-stretch.manifest.yaml';
        "${bootstrap_filepath}/manifests/cloud-buster.manifest.yaml":
            source  => 'puppet:///modules/labs_bootstrapvz/cloud-buster.manifest.yaml';
    }

    $projectregex = "s/${::wmcs_project}/_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 = lookup('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 debian::codename::lt('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',
    }
}