Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ Absolute path: defaults to `/etc/confd/`

Description: Specifies where all the configuration for confd will live

#####`downloadurl`

URL: defaults to `undef`.

Description: If set, the confd binary will be downloaded from this url instead of being taken from the sitemodule. Currently requires that the `version` parameter is set to the actual value reported by `confd --version` to ensure we have the required binary in place (the default `latest` value should be changed).

##### Other Parameters

All other parameters are directly mapped to the configuration in `confd.toml` please see the [documentation](https://github.com/kelseyhightower/confd/blob/master/docs/configuration-guide.md) for full details.
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$version = $confd::params::version,
$installdir = $confd::params::installdir,
$sitemodule = $confd::params::sitemodule,
$downloadurl = $confd::params::downloadurl,

$confdir = $confd::params::confdir,
$nodes = $confd::params::nodes,
Expand Down Expand Up @@ -34,6 +35,7 @@
validate_absolute_path($confdir)
validate_hash($resources)

if $downloadurl { validate_string($downloadurl) }
if $backend { validate_re($backend, ['^etcd$', '^consul$', '^zookeeper$', '^dynamodb$', '^redis$', '^env$']) }
if $debug { validate_bool($debug) }
if $interval { validate_re($interval, '^\d+') }
Expand Down
26 changes: 20 additions & 6 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@
include confd

$binary_src = "puppet:///modules/${confd::sitemodule}/confd-${confd::version}"
$binary_dst = "${confd::installdir}/confd"

file { "${confd::installdir}/confd":
ensure => present,
links => follow,
owner => 'root',
mode => '0750',
source => $binary_src
$owner = 'root'
$mode = '0750'
$links = 'follow'

if $confd::downloadurl {
confd::remote_file { $binary_dst:
url => $confd::downloadurl,
links => $links,
owner => $owner,
mode => $mode,
}
} else {
file { $binary_dst:
ensure => present,
source => $binary_src,
links => $links,
owner => $owner,
mode => $mode,
}
}
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$user = 'root'
$sitemodule = 'site_confd'
$nodes = ['127.0.0.1:4001']
$downloadurl = undef

case $::osfamily {
'Debian': {
Expand Down
23 changes: 23 additions & 0 deletions manifests/remote_file.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# == Resource confd::remote_file
#
define confd::remote_file($url, $owner='root', $mode='0750', $links='follow') {

include confd

$wget_cmd = "/usr/bin/wget -q"
$exists_check = "/usr/bin/test -f ${title}"
$version_check = "/usr/bin/test `${title} --version | awk '{print \$2}'` = '${confd::version}'"

exec { "download_${title}":
command => "${wget_cmd} ${url} -O ${title}",
unless => "${exists_check} && ${version_check}"
}

file { $title:
ensure => present,
mode => $mode,
owner => $owner,
links => $links,
require => Exec["download_${title}"],
}
}