summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/manifests/puppet_server.pp
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2018-04-14 20:07:19 +0200
committerJan Dittberner <jandd@cacert.org>2018-04-14 20:07:19 +0200
commit29f04d915c04547500c9cbf906d6a501e203aa6f (patch)
tree66a48fd034a997974713495bb26a02fec761dcb2 /sitemodules/profiles/manifests/puppet_server.pp
parent9be8e28751a0aa2d577d3e3f019173f00de97a2c (diff)
downloadcacert-puppet-29f04d915c04547500c9cbf906d6a501e203aa6f.tar.gz
cacert-puppet-29f04d915c04547500c9cbf906d6a501e203aa6f.tar.xz
cacert-puppet-29f04d915c04547500c9cbf906d6a501e203aa6f.zip
Add an HTTP hook for updating code on the puppet server
Diffstat (limited to 'sitemodules/profiles/manifests/puppet_server.pp')
-rw-r--r--sitemodules/profiles/manifests/puppet_server.pp86
1 files changed, 86 insertions, 0 deletions
diff --git a/sitemodules/profiles/manifests/puppet_server.pp b/sitemodules/profiles/manifests/puppet_server.pp
new file mode 100644
index 0000000..cf7bc9a
--- /dev/null
+++ b/sitemodules/profiles/manifests/puppet_server.pp
@@ -0,0 +1,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/environment/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'],
+ ],
+ }
+} \ No newline at end of file