Puppet Class: puppet_compiler

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

Overview

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    ensurable parameter

  • version (String) (defaults to: '2.3.1')

    the version of puppet compiler to install

  • workdir (Stdlib::Unixpath) (defaults to: '/srv/jenkins-workspace/puppet-compiler')

    main working directory

  • libdir (Stdlib::Unixpath) (defaults to: '/var/lib/catalog-differ')

    main software directory

  • user (String) (defaults to: 'jenkins-deploy')

    the user to run daemons

  • homedir (Stdlib::Unixpath) (defaults to: '/srv/home/jenkins-deploy')

    the useres home dir



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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'modules/puppet_compiler/manifests/init.pp', line 8

class puppet_compiler(
    Wmflib::Ensure   $ensure  = 'present',
    String           $version = '2.3.1',  # can and often is overridden in horizon
    Stdlib::Unixpath $workdir = '/srv/jenkins-workspace/puppet-compiler',
    Stdlib::Unixpath $libdir  = '/var/lib/catalog-differ',
    String           $user    = 'jenkins-deploy',
    Stdlib::Unixpath $homedir = '/srv/home/jenkins-deploy',
) {

    $vardir = "${libdir}/puppet"
    $yamldir = "${vardir}/yaml"
    $yaml_mount = '/mnt/nfs/labstore-secondary-project/yaml'

    ensure_packages([
        'python3-yaml', 'python3-requests', 'python3-jinja2', 'python3-clustershell',
        'nginx', 'ruby-httpclient', 'ruby-ldap', 'ruby-rgen', 'ruby-multi-json',
    ])
    file {'/usr/lib/ruby/vendor_ruby/puppet/application/master.rb':
        ensure  => stdlib::ensure($ensure, 'file'),
        content => file('puppet_compiler/puppet_master_pup-8187.rb.nocheck'),
    }

    # We cant use wmflib::dir::mkdir_p because the following creates /srv and /srv/jenkins-workspace
    # profile::ci::slave::labs::common
    file{
        default:
            ensure => stdlib::ensure($ensure, 'directory'),
            owner  => $user,
            mode   => '0644';
        [$workdir, $vardir]: ;
        $libdir:
            recurse => true;
        $yaml_mount:
            require => Labstore::Nfs_mount['project-on-labstore-secondary'],
            recurse => true;
        $yamldir:
            ensure => link,
            target => $yaml_mount;
    }

    if $ensure == 'present' {
        class { 'puppet_compiler::setup':
            user    => $user,
            vardir  => $vardir,
            homedir => $homedir,
        }
    }

    file { '/usr/local/bin/sshknowngen':
        ensure => absent,
    }
    # We don't really need some generators from puppet master, link them to
    # /bin/true
    file { '/usr/local/bin/naggen2':
        ensure => stdlib::ensure($ensure, 'link'),
        target => '/bin/true',
    }

    ## Git cloning

    # Git clone of the puppet repo
    git::clone { 'operations/puppet':
        ensure    => $ensure,
        directory => "${libdir}/production",
        owner     => $user,
        mode      => '0755',
        require   => File[$libdir],
    }

    # Git clone labs/private
    git::clone { 'labs/private':
        ensure    => $ensure,
        directory => "${libdir}/private",
        owner     => $user,
        mode      => '0755',
        require   => File[$libdir],
    }

    # Git clone labs/private
    git::clone { 'netbox-hiera':
        ensure    => $ensure,
        origin    => 'https://netbox-exports.wikimedia.org/netbox-hiera',
        directory => "${libdir}/netbox-hiera",
        owner     => $user,
        mode      => '0755',
        require   => File[$libdir],
    }

    $compiler_dir = "${libdir}/compiler"
    # Git clone the puppet compiler, install it
    git::install { 'operations/software/puppet-compiler':
        ensure    => $ensure,
        git_tag   => $version,
        directory => $compiler_dir,
        owner     => $user,
        notify    => Exec['install compiler'],
    }

    # Install the compiler
    exec { 'install compiler':
        command     => '/usr/bin/python3 setup.py install',
        user        => 'root',
        cwd         => $compiler_dir,
        refreshonly => true,
    }

    # configuration file
    file { '/etc/puppet-compiler.conf':
        ensure  => $ensure,
        owner   => $user,
        content => template('puppet_compiler/puppet-compiler.conf.erb'),
    }

    # A new, better approach is to just use confd independently. Here we
    # fake it with a file on disk
    file { '/etc/conftool-state':
        ensure => directory,
        mode   => '0755',
    }
    file { '/etc/conftool-state/mediawiki.yaml':
        ensure => stdlib::ensure($ensure, 'file'),
        mode   => '0444',
        source => 'puppet:///modules/puppet_compiler/mediawiki.yaml',
    }
    file { '/opt/puppetlabs/facter/cache/cached_facts/':
        owner => $user,
    }
}