summaryrefslogtreecommitdiffstats
path: root/puppet/modules/jenkins_server/manifests/debian.pp
blob: 2400b79562d63f5c20a6d3e51dfec0ad95bd168e (plain)
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
class jenkins_server::debian inherits jenkins_server
{

    # ================= jenkins package, service ================================

    exec { "install jenkins-ci apt-key":
        command => "/usr/bin/wget -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | /usr/bin/apt-key add -",
        unless => "/usr/bin/apt-key list | /bin/grep -q D50582E6",
        logoutput => true,
    }

    file { "/etc/apt/sources.list.d/jenkins.list":
        ensure => present,
        content => "deb http://pkg.jenkins-ci.org/debian binary/\n",
        require => Exec["install jenkins-ci apt-key"],
        notify => Exec["apt-get update for jenkins-ci"],
    }

    exec { "apt-get update for jenkins-ci":
        command => "/usr/bin/apt-get update",
        refreshonly => true,
        logoutput => true,
    }

    package { "jenkins":
        ensure => present,
        require => Exec["apt-get update for jenkins-ci"],
    }

    service { "jenkins":
        ensure => running,
        require => [
            Package["jenkins"],
        ],
    }

    # ============================= jenkins plugins =====================================

    file { "/var/lib/jenkins/plugins":
        ensure => directory,
        owner => 'jenkins',
        group => 'nogroup',
        require => Package["jenkins"],
    }

    jenkins_server::plugin {
        "git":;                       # git SCM support
        "build-publisher":;           # publish build results to another Jenkins
        "conditional-buildstep":;     # make commands conditional on OS or on master vs slave
        "envfile":;                   # send CI-related env vars from master to slave
        "extended-read-permission":;  # enables the extended read permission
        "groovy-postbuild":;          # offline / reboot hook
        "next-build-number":;         # allow manual set of build numbers
        "postbuildscript":;           # CI post-build task
        "preSCMbuildstep":;           # CI pre-build task
        "project-health-report":;     # shows how many build failed, and which testcases are the top breakers
        "publish-over-ssh":;          # enables artifact uploading to remote server
        "run-condition":;             # conditional-buildstep prereq
        "timestamper":;               # timestamps in build logs
        "token-macro":;               # expand macros in various places
        "email-ext":;                 # extended email plugin to allow direct e-mails from jenkins
    }


    # ============================= apache2 -> jenkins setup ===========================

    if $jenkins_server::apache2_frontend {
        package { "apache2":
            ensure => present,
        }

        service { "apache2":
            ensure => running,
            require => Package["apache2"],
        }

        file { "/etc/apache2/sites-available/jenkins":
            ensure => present,
            content => template("jenkins_server/apache-jenkins-site.conf.erb"),
            require => Package["apache2"],
        }

        exec { "/usr/sbin/a2enmod proxy":
            creates => "/etc/apache2/mods-enabled/proxy.load",
            require => Package["apache2"],
        }

        exec { "/usr/sbin/a2enmod proxy_http":
            creates => "/etc/apache2/mods-enabled/proxy_http.load",
            require => Package["apache2"],
        }

        exec { "/usr/sbin/a2enmod vhost_alias":
            creates => "/etc/apache2/mods-enabled/vhost_alias.load",
            require => Package["apache2"],
        }

        exec { "/usr/sbin/a2ensite jenkins":
            creates => "/etc/apache2/sites-enabled/jenkins",
            require => [
                File["/etc/apache2/sites-available/jenkins"],
                Exec["/usr/sbin/a2dissite default"],
            ],
            notify => Service["apache2"],
        }

        # 'default' site is sometimes linked as 'default', sometimes as '000-default' - not sure why
        exec { "/usr/sbin/a2dissite default":
            onlyif => "/usr/bin/test -e /etc/apache2/sites-enabled/default || \
                       /usr/bin/test -e /etc/apache2/sites-enabled/000-default",
            require => Package["apache2"],
        }
    }
}