From 46a421e01370d9dfdb06995ebbf84fee53bfe5af Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Thu, 15 Oct 2015 16:29:39 +0200 Subject: [PATCH] Refactor vcsrepo to git resource to resolve refresh trigger issues This patchset will replace the vcsrepo with puppet-community's git_resource and resolve the resource change notification issues. Change-Id: I4b0fc715f89062047ed32f4f89880ced76e54f9b --- README.md | 4 ++-- examples/site.pp | 19 +++++++++-------- manifests/init.pp | 44 ++++++++++++++++++++++++++++++++-------- manifests/install.pp | 4 ++-- manifests/site/config.pp | 8 ++++---- metadata.json | 4 ++-- 6 files changed, 55 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index cc10532..fb2f421 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ askbot_revision parameters. class { 'askbot': dist_root => '/srv/dist', site_root => '/srv/askbot-site', - askbot_revision => 'master', + askbot_branch => 'master', askbot_repo => 'https://github.com/ASKBOT/askbot-devel.git', www_user => 'www-data', www_group => 'www-data', @@ -81,6 +81,6 @@ OpenStack Askbot theme contains pure Sass files in the repository, for a production deployment those files must be compiled into css. askbot::theme::compass { 'os': - require => Vcsrepo['/srv/askbot-site/themes'], + require => Git['askbot-theme'], before => Exec['askbot-static-generate'], } diff --git a/examples/site.pp b/examples/site.pp index c030fcc..0fa039e 100644 --- a/examples/site.pp +++ b/examples/site.pp @@ -115,16 +115,17 @@ node 'default' { } # custom theme - vcsrepo { '/srv/askbot-site/themes': - ensure => latest, - provider => git, - revision => 'feature/development', - source => 'https://git.openstack.org/openstack-infra/askbot-theme', - require => [ + git { 'askbot-theme': + ensure => present, + path => '/srv/askbot-site/themes', + branch => 'feature/development', + origin => 'https://git.openstack.org/openstack-infra/askbot-theme', + latest => true, + require => [ File['/srv/askbot-site'], Package['git'] ], - before => Exec['askbot-syncdb'], - notify => [ + before => Exec['askbot-syncdb'], + notify => [ Exec['theme-bundle-install-os'], Exec['theme-bundle-compile-os'], Exec['askbot-static-generate'], @@ -132,7 +133,7 @@ node 'default' { } askbot::theme::compass { 'os': - require => Vcsrepo['/srv/askbot-site/themes'], + require => Git['askbot-theme'], before => Exec['askbot-static-generate'], } } diff --git a/manifests/init.pp b/manifests/init.pp index e7bc935..c4baf52 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,7 +12,10 @@ # # Source repository: # - askbot_repo: git repository of askbot source files -# - askbot_revision: branch of askbot repo used for deployment +# - versions to checkout (askbot_revision|askbot_branch|askbot_tag) +# - askbot_revision: commit ref of askbot repo used for deployment +# - askbot_branch: branch of askbot repo +# - askbot_tag: a specific version or tag of the askbot repo # # Custom askbot theme settings: # - $custom_theme_enabled: set to true to enable custom themes, default: false @@ -56,7 +59,9 @@ class askbot ( $redis_password, $dist_root = '/srv/dist', $site_root = '/srv/askbot-site', - $askbot_revision = 'master', + $askbot_branch = 'master', + $askbot_tag = undef, + $askbot_revision = undef, $askbot_repo = 'https://github.com/ASKBOT/askbot-devel.git', $www_group = 'www-data', $www_user = 'www-data', @@ -105,12 +110,33 @@ class askbot ( } } - vcsrepo { "${dist_root}/askbot": - ensure => $askbot_ensure, - provider => git, - revision => $askbot_revision, - source => $askbot_repo, - require => [ File[$dist_root], Package['git'] ], + if ($askbot_revision) { + git { 'askbot': + ensure => present, + path => "${dist_root}/askbot", + origin => $askbot_repo, + latest => true, + commit => $askbot_revision, + require => [ File[$dist_root], Package['git'] ], + } + } elsif ($askbot_tag) { + git { 'askbot': + ensure => present, + path => "${dist_root}/askbot", + origin => $askbot_repo, + latest => true, + tag => $askbot_tag, + require => [ File[$dist_root], Package['git'] ], + } + } else { + git { 'askbot': + ensure => present, + path => "${dist_root}/askbot", + origin => $askbot_repo, + latest => true, + branch => $askbot_branch, + require => [ File[$dist_root], Package['git'] ], + } } class { '::askbot::config': @@ -143,6 +169,6 @@ class askbot ( smtp_port => $smtp_port, smtp_host => $smtp_host, template_settings => $template_settings, - require => [ Vcsrepo["${dist_root}/askbot"], Class['askbot::install'] ], + require => [ Git['askbot'], Class['askbot::install'] ], } } diff --git a/manifests/install.pp b/manifests/install.pp index a791114..45f6106 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -89,7 +89,7 @@ class askbot::install ( command => "/usr/askbot-env/bin/pip install -q -r ${dist_root}/askbot/askbot_requirements.txt", cwd => "${dist_root}/askbot", logoutput => on_failure, - subscribe => Vcsrepo["${dist_root}/askbot"], + subscribe => Git['askbot'], refreshonly => true, } @@ -107,7 +107,7 @@ class askbot::install ( cwd => "${dist_root}/askbot", command => '/usr/askbot-env/bin/python setup.py -q install', logoutput => on_failure, - subscribe => Vcsrepo["${dist_root}/askbot"], + subscribe => Git['askbot'], refreshonly => true, require => Exec[ 'pip-requirements-install'], } diff --git a/manifests/site/config.pp b/manifests/site/config.pp index f03a40a..a060a18 100644 --- a/manifests/site/config.pp +++ b/manifests/site/config.pp @@ -70,14 +70,14 @@ class askbot::site::config ( File["${site_root}/log"], Askbot::Site::Setup_template[ $setup_templates ], File["${site_root}/config/settings.py"], - Vcsrepo["${dist_root}/askbot"], + Git['askbot'], ] exec { 'askbot-static-generate': cwd => "${site_root}/config", command => '/usr/askbot-env/bin/python manage.py collectstatic --noinput', require => $post_config_dependency, - subscribe => [Vcsrepo["${dist_root}/askbot"], File["${site_root}/config/settings.py"] ], + subscribe => [Git['askbot'], File["${site_root}/config/settings.py"] ], refreshonly => true, } @@ -85,7 +85,7 @@ class askbot::site::config ( cwd => "${site_root}/config", command => '/usr/askbot-env/bin/python manage.py syncdb --noinput', require => $post_config_dependency, - subscribe => [Vcsrepo["${dist_root}/askbot"], File["${site_root}/config/settings.py"] ], + subscribe => [Git['askbot'], File["${site_root}/config/settings.py"] ], refreshonly => true, } @@ -94,7 +94,7 @@ class askbot::site::config ( cwd => "${site_root}/config", command => '/usr/askbot-env/bin/python manage.py migrate --noinput', require => Exec['askbot-syncdb'], - subscribe => [Vcsrepo["${dist_root}/askbot"], File["${site_root}/config/settings.py"] ], + subscribe => [Git['askbot'], File["${site_root}/config/settings.py"] ], refreshonly => true, } diff --git a/metadata.json b/metadata.json index e69d143..c91e349 100644 --- a/metadata.json +++ b/metadata.json @@ -24,7 +24,7 @@ { "name": "puppetlabs/mysql", "version_requirement": "= 0.6.1" }, { "name": "openstackinfra/httpd", "version_requirement": "0.x" }, { "name": "openstackinfra/redis", "version_requirement": "= 0.0.1" }, - { "name": "openstackinfra/vcsrepo", "version_requirement": "= 0.0.1" }, - { "name": "stankevich/python", "version_requirement": "= 1.9.4" } + { "name": "stankevich/python", "version_requirement": "= 1.9.4" }, + { "name": "puppet-community/git_resource", "version_requirement": "= 0.3.0" } ] }