Skip to content

Instantly share code, notes, and snippets.

@sycobuny
Created February 16, 2012 03:15
Show Gist options
  • Select an option

  • Save sycobuny/1841425 to your computer and use it in GitHub Desktop.

Select an option

Save sycobuny/1841425 to your computer and use it in GitHub Desktop.
A simple example of a puppet config with git automatic deployment based on "release-#" tags
class git {
package { 'git-core':
ensure => installed,
}
define web_project($project = $name, $dir = "/var/www/${project}") {
exec { "web-git-reset-${name}":
require => Package['git-core'],
command => "git reset --hard HEAD",
cwd => $dir,
}
exec { "web-git-clean-${name}":
require => Exec["web-git-reset-${name}"],
command => "git clean -f",
cwd => $dir,
}
exec { "web-git-fetch-${name}":
require => Exec["web-git-clean-${name}"],
command => "git fetch origin",
cwd => $dir,
}
exec { "web-git-checkout-${name}":
require => Exec["web-git-fetch-${name}"],
command => "git checkout \"release-\$(git tag | cut -d\\- -f2 | sort -rn | head -n1)\"",
cwd => $dir,
}
}
}
node webserver {
# various setup for web server
$git_web_projects = ['blog', 'analytics', 'main_site']
git::web_project { $git_web_projects: }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment