Defined Type: psick::bolt::project
- Defined in:
- manifests/bolt/project.pp
Summary
This define creates a bolt project directory.Overview
It allows to customise the contents of all the relevant files and it can be integrated over a Puppet control-repo, to clone from a given $control_repo_url. By default everything is cretaed in a directory called Boltdir in the home passed as title. It’s possible to specify a different $user (using whatever title) or a different destination $path
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'manifests/bolt/project.pp', line 35
define psick::bolt::project (
Psick::Ensure $ensure = 'present',
String $user = $title,
Optional[String] $group = undef,
String $mode = '0640',
Boolean $replace = true,
Boolean $user_manage = false,
Hash $user_options_hash = {}, # Hash of options for psick::users::managed
Optional[Stdlib::Absolutepath] $path = undef,
Boolean $use_default_config_files_hash = true,
Hash $config_files_hash = {},
String $bolt_yaml_template = 'psick/bolt/project/bolt.yaml.epp',
Optional[String] $inventory_yaml_template = undef,
Hash $options_hash = {},
Optional[String] $data_repo_url = undef,
Boolean $control_repo_integrate = false,
Psick::Url $control_repo_url = 'https://github.com/example42/psick',
Boolean $puppetfile_install = false,
) {
$home_dir = pick($path, psick::get_user_home($user))
$bolt_dir = "${home_dir}/Boltdir"
File {
ensure => $ensure,
owner => $user,
group => $group,
mode => $mode,
replace => $replace,
require => $control_repo_integrate ? {
true => Tp::Dir[$bolt_dir],
false => undef,
}
}
if $control_repo_integrate {
tp::dir { $bolt_dir:
ensure => $ensure,
source => $control_repo_url,
vcsrepo => 'git',
}
} else {
file { $bolt_dir:
ensure => tp::ensure2dir($ensure),
}
}
$default_config_hash = {
['modules' , 'site-modules'] => {
ensure => tp::ensure2dir($ensure),
},
'bolt.yaml' => {
content => psick::template($bolt_yaml_template),
},
'inventory.yaml' => {
content => psick::template($inventory_yaml_template),
},
}
if $data_repo_url {
# tp::dir handles file resource data
tp::dir { "${bolt_dir}/data":
source => $data_repo_url,
vcsrepo => 'git',
}
$data_dir_config_hash = {}
} else {
if $use_default_config_files_hash {
$data_dir_config_hash = {
'data' => {
ensure => tp::ensure2dir($ensure),
},
}
} else {
$data_dir_config_hash = {}
}
}
if $user_manage {
user { $user:
* => $user_options_hash,
}
}
$all_files_hash = $use_default_config_files_hash ? {
true => $default_config_hash + $data_dir_config_hash + $config_files_hash,
false => $data_dir_config_hash + $config_files_hash,
}
$all_files_hash.each | $k,$v | {
file { "${bolt_dir}/${k}":
* => $v,
}
}
if $puppetfile_install {
exec { 'bolt install puppetfile':
path => $facts['path'],
cwd => $bolt_dir,
creates => 'modules/stdlib', # Quick and very dirty
}
}
}
|