summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/manifests/puppet_server.pp
blob: 073011264934be7e637e490b10e0c1201abc1e31 (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
# Class: profiles::puppet_server
# ==============================
#
# This class takes care of resources on the puppet server
#
# Parameters
# ----------
#
# @param git_pull_ssh_passphrase passphrase to use for the ssh key to pull
#                                new code from the control repository
# @param git_pull_directory      directory where the puppet control repository
#                                is checked out
# @param git_pull_tokens         list of tokens that are valid to trigger the
#                                git pull hook
#
# Examples
# --------
#
# @example
#   class roles::myhost {
#     include profiles::puppet_server
#   }
#
# Authors
# -------
#
# Jan Dittberner <jandd@cacert.org>
#
# Copyright
# ---------
#
# Copyright 2018 Jan Dittberner
class profiles::puppet_server (
  String $git_pull_ssh_passphrase,
  String $git_pull_directory = '/etc/puppetlabs/code/environments/production',
  Array[String] $git_pull_tokens,
) {
  package { 'sshpass':
    ensure => installed,
  }

  package { 'git':
    ensure => installed,
  }

  file { '/usr/local/sbin/git-pull-hook':
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0750',
    source  => 'puppet:///modules/profiles/puppet_server/git-pull-hook',
    require => [Package['sshpass'], Package['git']],
  }

  file { '/etc/init.d/git-pull-hook':
    ensure => file,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
    source => 'puppet:///modules/profiles/puppet_server/git-pull-hook.init.sh'
  }

  file { '/etc/git-pull-hook.ini':
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0400',
    content => epp(
      'profiles/puppet_server/git-pull-hook.ini.epp',
      {
        'ssh_passphrase' => $git_pull_ssh_passphrase,
        'tokens'         => $git_pull_tokens,
        'git_directory'  => $git_pull_directory,
      }
    )
  }

  service { 'git-pull-hook':
    ensure  => running,
    enable  => true,
    require => [
      File['/etc/init.d/git-pull-hook'], File['/usr/local/sbin/git-pull-hook'],
      File['/etc/git-pull-hook.ini'],
    ],
  }
}