Index: modules/rietveld/manifests/init.pp |
=================================================================== |
--- a/modules/rietveld/manifests/init.pp |
+++ b/modules/rietveld/manifests/init.pp |
@@ -85,4 +85,46 @@ |
cwd => "${rietveld_home}", |
require => Exec['install_rietveld'], |
} |
+ |
+ file {"${rietveld_home}/fixtures": |
+ ensure => directory, |
+ owner => 'rietveld', |
+ mode => 0750, |
+ require => Exec['install_rietveld'], |
+ } |
+ |
+ define fixture( |
+ $ensure = present, |
+ $source = undef, |
+ $content = undef, |
+ ) { |
+ |
+ # Note that $script will return EXIT_SUCCESS when the .type is |
+ # not recognized - although no action is done then. Thus we enforce |
+ # JSON here, which is the default for command "dumpdata" anyway: |
+ $script = "${rietveld::rietveld_home}/manage.py" |
+ $destination = "${rietveld::rietveld_home}/fixtures/$name.json" |
+ |
+ exec {$destination: |
+ command => shellquote($script, 'loaddata', $destination), |
+ cwd => $rietveld::rietveld_home, |
+ refreshonly => true, |
+ user => 'rietveld', |
+ } |
+ |
+ file {$destination: |
+ ensure => $ensure, |
+ content => $content, |
+ source => $source, |
+ owner => 'rietveld', |
+ mode => 0640, |
+ notify => $ensure ? { |
+ present => Exec[$destination], |
+ default => [], |
+ } |
+ } |
+ } |
+ |
+ $fixtures = hiera('rietveld_fixtures', {}) |
+ create_resources(rietveld::fixture, $fixtures) |
} |