|
98 | 98 | # is managed for us in postgresql::server::config. |
99 | 99 | if $facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Ubuntu' { |
100 | 100 | if $name == 'data_directory' { |
| 101 | + $stop_command = ['service', $postgresql::server::service_name, 'stop'] |
| 102 | + $stop_onlyif = ['service', $postgresql::server::service_name, 'status'] |
| 103 | + $stop_unless = [['grep', "data_directory = '${value}'", $postgresql::server::postgresql_conf_path]] |
101 | 104 | exec { "postgresql_stop_${name}": |
102 | | - command => "service ${postgresql::server::service_name} stop", |
103 | | - onlyif => "service ${postgresql::server::service_name} status", |
104 | | - unless => "grep \"data_directory = '${value}'\" ${postgresql::server::postgresql_conf_path}", |
| 105 | + command => $stop_command, |
| 106 | + onlyif => $stop_onlyif, |
| 107 | + unless => $stop_unless, |
105 | 108 | path => '/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin', |
106 | 109 | before => Postgresql_conf[$name], |
107 | 110 | } |
|
111 | 114 | # We need to force postgresql to stop before updating the port |
112 | 115 | # because puppet becomes confused and is unable to manage the |
113 | 116 | # service appropriately. |
| 117 | + $stop_command = ['service', $postgresql::server::service_name, 'stop'] |
| 118 | + $stop_onlyif = ['service', $postgresql::server::service_name, 'status'] |
| 119 | + $stop_unless = "grep 'PGPORT=${shell_escape($value)}' /etc/sysconfig/pgsql/postgresql" |
114 | 120 | exec { "postgresql_stop_${name}": |
115 | | - command => "service ${postgresql::server::service_name} stop", |
116 | | - onlyif => "service ${postgresql::server::service_name} status", |
117 | | - unless => "grep 'PGPORT=${value}' /etc/sysconfig/pgsql/postgresql", |
| 121 | + command => $stop_command, |
| 122 | + onlyif => $stop_onlyif, |
| 123 | + unless => $stop_unless, |
118 | 124 | path => '/sbin:/bin:/usr/bin:/usr/local/bin', |
119 | 125 | require => File['/etc/sysconfig/pgsql/postgresql'], |
120 | 126 | } |
|
130 | 136 | } elsif $name == 'data_directory' { |
131 | 137 | # We need to force postgresql to stop before updating the data directory |
132 | 138 | # otherwise init script breaks |
| 139 | + $stop_command = ['service', $postgresql::server::service_name, 'stop'] |
| 140 | + $stop_onlyif = ['service', $postgresql::server::service_name, 'status'] |
| 141 | + $stop_unless = [['grep', "PGDATA=${value}", '/etc/sysconfig/pgsql/postgresql']] |
133 | 142 | exec { "postgresql_${name}": |
134 | | - command => "service ${postgresql::server::service_name} stop", |
135 | | - onlyif => "service ${postgresql::server::service_name} status", |
136 | | - unless => "grep 'PGDATA=${value}' /etc/sysconfig/pgsql/postgresql", |
| 143 | + command => $stop_command, |
| 144 | + onlyif => $stop_onlyif, |
| 145 | + unless => $stop_unless, |
137 | 146 | path => '/sbin:/bin:/usr/bin:/usr/local/bin', |
138 | 147 | require => File['/etc/sysconfig/pgsql/postgresql'], |
139 | 148 | } |
|
0 commit comments