1
0
mirror of https://github.com/krislamo/puppet-acme_vault synced 2024-11-10 04:40:35 +00:00
puppet-acme_vault/manifests/common.pp

91 lines
2.4 KiB
ObjectPascal
Raw Normal View History

2018-02-27 18:58:42 +00:00
# Common configuration for acme_vault
2020-08-11 20:11:20 +00:00
#
2018-02-27 18:58:42 +00:00
class acme_vault::common (
$user = $::acme_vault::params::user,
$group = $::acme_vault::params::group,
$home_dir = $::acme_vault::params::home_dir,
$contact_email = $::acme_vault::params::contact_email,
2018-03-01 20:59:07 +00:00
$domains = $::acme_vault::params::domains,
2019-08-08 16:01:55 +00:00
$overrides = $::acme_vault::params::overrides,
$vault_token = $::acme_vault::params::vault_token,
$vault_addr = $::acme_vault::params::vault_addr,
$vault_bin = $::acme_vault::params::vault_bin,
$vault_prefix = $::acme_vault::params::vault_prefix,
) inherits acme_vault::params {
$common_bashrc_template = @(END)
2020-08-11 20:11:20 +00:00
export PATH=$HOME:$PATH
export VAULT_BIN=<%= @vault_bin %>
export VAULT_TOKEN=<%= @vault_token %>
export VAULT_ADDR=<%= @vault_addr %>
export VAULT_PREFIX=<%= @vault_prefix %>
| END
# create acme_vault user
user { $user:
ensure => present,
gid => $group,
system => true,
home => $home_dir,
managehome => true,
}
file { $home_dir:
ensure => directory,
owner => $user,
group => $group,
2018-02-26 19:54:07 +00:00
mode => '0750',
}
# vault module isn't too flexible for install only, just copy in binary
# would be nice if this worked!
#class { '::vault::install':
# manage_user => false,
#}
2018-02-26 19:54:07 +00:00
file { $vault_bin:
ensure => present,
2018-02-26 19:54:07 +00:00
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/acme_vault/vault',
}
# variables in bashrc
concat { "${home_dir}/.bashrc":
2018-02-26 19:54:07 +00:00
owner => $user,
group => $group,
mode => '0600',
}
2018-02-26 19:54:07 +00:00
concat::fragment{ 'vault_bashrc':
target => "${home_dir}/.bashrc",
content => inline_template($common_bashrc_template),
2018-02-26 19:54:07 +00:00
order => '01',
}
# common dummy cron job to set MAILTO
2018-02-26 19:54:07 +00:00
cron { 'dummy_mailto':
command => '/bin/true',
user => $user,
month => 7,
2018-03-05 18:23:44 +00:00
hour => 1,
minute => 29,
environment => "MAILTO=${contact_email}",
}
# renew vault token
cron { 'renew vault token':
2018-03-05 18:23:44 +00:00
command => ". \$HOME/.bashrc && $vault_bin token-renew > /dev/null",
user => $user,
weekday => 1,
2018-03-05 18:23:44 +00:00
hour => 10,
minute => 17,
}
}