Puppet Class: puppet_compiler

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

Overview

Installs the puppet compiler and all the other software we need.

Parameters:

  • version (Any) (defaults to: '0.7.2')
  • workdir (Any) (defaults to: '/srv/jenkins-workspace/puppet-compiler')
  • libdir (Any) (defaults to: '/var/lib/catalog-differ')
  • ensure (Any) (defaults to: 'present')
  • user (Any) (defaults to: 'jenkins-deploy')
  • homedir (Any) (defaults to: '/srv/home/jenkins-deploy')


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

class puppet_compiler(
    $version = '0.7.2',  # The compiler* hosts override this in horizon
    $workdir = '/srv/jenkins-workspace/puppet-compiler',
    $libdir  = '/var/lib/catalog-differ',
    $ensure  = 'present',
    $user    = 'jenkins-deploy',
    $homedir = '/srv/home/jenkins-deploy',
    ) {

    require puppet_compiler::packages

    $vardir = "${libdir}/puppet"

    file { [$libdir, $vardir, $workdir]:
        ensure => ensure_directory($ensure),
        owner  => $user,
        mode   => '0644',
    }
    File[$libdir] {
        recurse => true,
    }

    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 => ensure_link($ensure),
        target => '/bin/true',
    }

    include puppet_compiler::web

    ## 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],
    }

    $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/python 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'),
    }


    # The conftool parser function needs
    # An etcd instance running populated with (fake? synced?) data

    include etcd
    # 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 => present,
        mode   => '0444',
        source => 'puppet:///modules/puppet_compiler/mediawiki.yaml'
    }

    tidy { "${puppet_compiler::workdir}/output":
        recurse => true,
        age     => '6w',
        rmdirs  => true,
    }

    class { 'puppetmaster::puppetdb::client':
        hosts => [$::fqdn],
    }
    # puppetdb configuration
    file { "${vardir}/puppetdb.conf":
        source  => '/etc/puppet/puppetdb.conf',
        owner   => $user,
        require => File['/etc/puppet/puppetdb.conf']
    }

    # periodic script to populate puppetdb. Run at 4 AM every sunday.
    cron { 'Populate puppetdb':
        command => "/usr/local/bin/puppetdb-populate --basedir ${libdir} > ${homedir}/puppetdb-populate.log 2>&1",
        user    => $user,
        hour    => 4,
        minute  => 0,
        weekday => 0,
    }
}