mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
The construction `su postgres -c -- bash -c 'psql …'` didn’t behave the way it reads, and only worked by accident: 1. `-c --` sets the command to `--`. 2. `bash` sets the first argument to `bash`. 3. `-c 'psql …'` replaces the command with `psql …`. Thus, `su` ended up executing `<shell> -c 'psql …' bash`, where `<shell>` is the `postgres` user’s login shell, usually also `bash`, which then executed 'psql …' and ignored the extra `bash`. Unconfuse this construction. Note from tabbott: The old code didn't even work by accident, it was just broken. The right fix is to move the quoting around properly. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
42 lines
1.4 KiB
Puppet
42 lines
1.4 KiB
Puppet
class zulip_ops::postgres_master {
|
|
include zulip_ops::base
|
|
include zulip_ops::postgres_appdb
|
|
|
|
$master_packages = [# Packages needed for disk + RAID configuration
|
|
'xfsprogs',
|
|
'mdadm',
|
|
]
|
|
package { $master_packages: ensure => 'installed' }
|
|
|
|
file { '/etc/sysctl.d/40-postgresql.conf':
|
|
ensure => file,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0644',
|
|
source => 'puppet:///modules/zulip_ops/postgresql/40-postgresql.conf.master',
|
|
}
|
|
|
|
file { '/root/setup_disks.sh':
|
|
ensure => file,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0744',
|
|
source => 'puppet:///modules/zulip_ops/postgresql/setup_disks.sh',
|
|
}
|
|
|
|
exec { 'setup_disks':
|
|
command => '/root/setup_disks.sh',
|
|
require => Package["postgresql-${zulip::base::postgres_version}", 'xfsprogs', 'mdadm'],
|
|
creates => '/dev/md0'
|
|
}
|
|
|
|
# This one will probably fail most of the time
|
|
exec {'give_nagios_user_access':
|
|
# lint:ignore:140chars
|
|
command => "bash -c \"su postgres -c 'psql -v ON_ERROR_STOP=1 zulip < /usr/share/postgresql/${zulip::base::postgres_version}/zulip_nagios_setup.sql' && touch /usr/share/postgresql/${zulip::base::postgres_version}/zulip_nagios_setup.sql.applied\"",
|
|
# lint:endignore
|
|
creates => "/usr/share/postgresql/${zulip::base::postgres_version}/zulip_nagios_setup.sql.applied",
|
|
require => Package["postgresql-${zulip::base::postgres_version}"],
|
|
}
|
|
}
|