File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 33 $dbname = $title,
44 $owner = $postgresql::server::user,
55 $tablespace = undef ,
6+ $template = ' template0' ,
67 $encoding = $postgresql::server::encoding,
78 $locale = $postgresql::server::locale,
89 $istemplate = false
4344 default => " --tablespace='${tablespace} ' " ,
4445 }
4546
46- $createdb_command = " ${createdb_path} --owner='${owner} ' --template=template0 ${encoding_option}${locale_option}${tablespace_option} '${dbname} '"
47+ $createdb_command = " ${createdb_path} --owner='${owner} ' --template=${template} ${encoding_option}${locale_option}${tablespace_option} '${dbname} '"
4748
4849 postgresql_psql { "Check for existence of db '${dbname}'" :
4950 command => ' SELECT 1' ,
Original file line number Diff line number Diff line change 77 $locale = $postgresql::server::locale,
88 $grant = ' ALL' ,
99 $tablespace = undef ,
10+ $template = ' template0' ,
1011 $istemplate = false ,
1112 $owner = undef
1213) {
1314 postgresql::server::database { $name:
1415 encoding => $encoding ,
1516 tablespace => $tablespace ,
17+ template => $template ,
1618 locale => $locale ,
1719 istemplate => $istemplate ,
1820 owner => $owner ,
Original file line number Diff line number Diff line change @@ -140,4 +140,35 @@ class { 'postgresql::server': }
140140 end
141141 end
142142 end
143+
144+ it 'should take a template parameter' do
145+ begin
146+ pp = <<-EOS . unindent
147+ $db = 'postgresql_test_db'
148+ class { 'postgresql::server': }
149+
150+ postgresql::server::db { $db:
151+ user => $db,
152+ template => 'template1',
153+ password => postgresql_password($db, $db),
154+ }
155+ EOS
156+
157+ puppet_apply ( pp ) do |r |
158+ r . exit_code . should_not == 1
159+ r . refresh
160+ r . exit_code . should == 0
161+ end
162+
163+ psql ( '--command="select datname from pg_database" postgresql_test_db' ) do |r |
164+ r . stdout . should =~ /postgresql_test_db/
165+ r . stderr . should be_empty
166+ r . exit_code . should == 0
167+ end
168+ ensure
169+ psql ( '--command="drop database postgresql_test_db" postgres' ) do |r |
170+ r . exit_code . should == 0
171+ end
172+ end
173+ end
143174end
You can’t perform that action at this time.
0 commit comments