Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't call puppet multiple times in prepare host for acceptance #892

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions spec/support/acceptance/prepare_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,36 @@ def prepare_host
# does not exist. Symlink it from /bin/mkdir to make it work.
shell('ln -sf /bin/mkdir /usr/bin/mkdir') if fact('os.distro.id') == 'Debian'

cleanup_script_debian = <<-SHELL
/opt/puppetlabs/bin/puppet resource service zabbix-server ensure=stopped
/opt/puppetlabs/bin/puppet resource service apache2 ensure=stopped
/opt/puppetlabs/bin/puppet resource package zabbix-server-pgsql ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-frontend-php ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-sql-scripts ensure=purged
/opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a
rm -f /etc/zabbix/.*done
if id postgres > /dev/null 2>&1; then
su - postgres -c "psql -c 'drop database if exists zabbix_server;'"
fi
cleanup_puppet = <<-SHELL
$services = $facts['os']['family'] ? {
'RedHat' => ['zabbix-server', 'httpd'],
'Debian' => ['zabbix-server', 'apache2'],
default => [],
}
service { $services:
ensure => stopped
}

$packages = $facts['os']['family'] ? {
'RedHat' => ['zabbix-server-pgsql', 'zabbix-server-pgsql-scl', 'zabbix-web', 'zabbix-web-pgsql', 'zabbix-web-pgsql-scl', 'zabbix-frontend-php', 'zabbix-sql-scripts'],
'Debian' => ['zabbix-server-pgsql', 'zabbix-web-pgsql', 'zabbix-frontend-php', 'zabbix-sql-scripts'],
default => [],
}
package { $packages:
ensure => purged
}
SHELL

cleanup_script_redhat = <<-SHELL
/opt/puppetlabs/bin/puppet resource service zabbix-server ensure=stopped
/opt/puppetlabs/bin/puppet resource service httpd ensure=stopped
/opt/puppetlabs/bin/puppet resource package zabbix-server-pgsql ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-server-pgsql-scl ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-web ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql-scl ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-frontend-php ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-sql-scripts ensure=purged
cleanup_script = <<-SHELL
/opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a
rm -f /etc/zabbix/.*done
if id postgres > /dev/null 2>&1; then
su - postgres -c "psql -c 'drop database if exists zabbix_server;'"
fi
SHELL

shell(cleanup_script_debian) if fact('os.family') == 'Debian'
shell(cleanup_script_redhat) if fact('os.family') == 'RedHat'
apply_manifest(cleanup_puppet)
shell(cleanup_script)

install_deps = <<-SHELL
$compile_packages = $facts['os']['family'] ? {
Expand Down