Skip to content

Instantly share code, notes, and snippets.

@droopy4096
Created February 9, 2018 23:05
Show Gist options
  • Save droopy4096/1a1b54e7b2025c7616d47c951d5b6782 to your computer and use it in GitHub Desktop.
Save droopy4096/1a1b54e7b2025c7616d47c951d5b6782 to your computer and use it in GitHub Desktop.
docker compose wrapper with vcsrepo
define compose_setup(
$compose_source_repo,
$compose_source_revision,
$compose_deploy_dir,
$compose_ensure='present',
$compose_file='docker-compose.yml',
$compose_identity=undef,
$compose_stage_dir=undef,
$compose_source_repo_force=false,
$compose_ensure='latest',
$compose_provider='git',
$compose_options=[],
$compose_up_args=[],
) {
if($compose_stage_dir) {
$deploy_dir=$compose_stage_dir
} else {
$deploy_dir=$title
}
vcsrepo { $compose_stage_dir :
ensure => $compose_ensure,
provider => $compose_provider,
source => $compose_source_repo,
identity => $compose_identity,
force => $compose_source_repo_force,
revision => $compose_source_revision,
}
~> file { $compose_deploy_dir:
ensure => present,
source => $compose_stage_dir,
recurse => true,
purge => true,
notify => Docker_compose["${compose_deploy_dir}/${compose_file}"],
}
### Need to use transition ( https://forge.puppet.com/puppetlabs/transition)
### here
transition { 'stop ${title} compose':
resource => Docker_compose["${compose_deploy_dir}/docker-compose.yml"],
attributes => { ensure => "absent" },
prior_to => File[$compose_deploy_dir],
}
docker_compose { "${compose_deploy_dir}/docker-compose.yml":
ensure => $compose_ensure,
cwd => $compose_deploy_dir,
options => $compose_options,
up_args => $compose_up_args,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment