|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | def prepare_host |
4 | | - if fact('os.family') == 'RedHat' |
5 | | - shell('rm -rf /etc/yum.repos.d/Zabbix*.repo; rm -rf /var/cache/yum/x86_64/*/Zabbix*; yum clean all --verbose') |
6 | | - # The CentOS docker image has a yum config that won't install docs, to keep used space low |
7 | | - # zabbix packages their SQL file as doc, we need that for bootstrapping the database |
8 | | - shell('sed -i "/nodocs/d" /etc/yum.conf') if fact('os.release.major').to_i == 7 |
9 | | - end |
| 4 | + shell('yum clean all --verbose; rm -rf /etc/yum.repos.d/Zabbix*.repo') if fact('os.family') == 'RedHat' |
10 | 5 |
|
11 | | - # The Ubuntu 18.04+ docker image has a dpkg config that won't install docs, to keep used space low |
12 | | - # zabbix packages their SQL file as doc, we need that for bootstrapping the database |
13 | | - shell('rm -f /etc/dpkg/dpkg.cfg.d/excludes') if fact('os.distro.id') == 'Ubuntu' |
| 6 | + apply_manifest <<~PUPPET |
| 7 | + $services = $facts['os']['family'] ? { |
| 8 | + 'RedHat' => ['zabbix-server', 'httpd'], |
| 9 | + 'Debian' => ['zabbix-server', 'apache2'], |
| 10 | + default => [], |
| 11 | + } |
| 12 | + service { $services: |
| 13 | + ensure => stopped |
| 14 | + } |
14 | 15 |
|
15 | | - # On Debian it seems that make is searching for mkdir in /usr/bin/ but mkdir |
16 | | - # does not exist. Symlink it from /bin/mkdir to make it work. |
17 | | - shell('ln -sf /bin/mkdir /usr/bin/mkdir') if fact('os.distro.id') == 'Debian' |
| 16 | + $packages = $facts['os']['family'] ? { |
| 17 | + 'RedHat' => ['zabbix-server-pgsql', 'zabbix-server-pgsql-scl', 'zabbix-web', 'zabbix-web-pgsql', 'zabbix-web-pgsql-scl', 'zabbix-frontend-php', 'zabbix-sql-scripts'], |
| 18 | + 'Debian' => ['zabbix-server-pgsql', 'zabbix-web-pgsql', 'zabbix-frontend-php', 'zabbix-sql-scripts'], |
| 19 | + default => [], |
| 20 | + } |
| 21 | + package { $packages: |
| 22 | + ensure => purged |
| 23 | + } |
| 24 | + PUPPET |
18 | 25 |
|
19 | | - cleanup_puppet = <<-SHELL |
20 | | - $services = $facts['os']['family'] ? { |
21 | | - 'RedHat' => ['zabbix-server', 'httpd'], |
22 | | - 'Debian' => ['zabbix-server', 'apache2'], |
23 | | - default => [], |
24 | | - } |
25 | | - service { $services: |
26 | | - ensure => stopped |
27 | | - } |
28 | | -
|
29 | | - $packages = $facts['os']['family'] ? { |
30 | | - 'RedHat' => ['zabbix-server-pgsql', 'zabbix-server-pgsql-scl', 'zabbix-web', 'zabbix-web-pgsql', 'zabbix-web-pgsql-scl', 'zabbix-frontend-php', 'zabbix-sql-scripts'], |
31 | | - 'Debian' => ['zabbix-server-pgsql', 'zabbix-web-pgsql', 'zabbix-frontend-php', 'zabbix-sql-scripts'], |
32 | | - default => [], |
33 | | - } |
34 | | - package { $packages: |
35 | | - ensure => purged |
36 | | - } |
37 | | - SHELL |
38 | | - |
39 | | - cleanup_script = <<-SHELL |
40 | | - /opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a |
41 | | - rm -f /etc/zabbix/.*done |
42 | | - if id postgres > /dev/null 2>&1; then |
43 | | - su - postgres -c "psql -c 'drop database if exists zabbix_server;'" |
44 | | - fi |
| 26 | + shell <<~SHELL |
| 27 | + /opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a |
| 28 | + rm -f /etc/zabbix/.*done |
| 29 | + if id postgres > /dev/null 2>&1; then |
| 30 | + su - postgres -c "psql -c 'drop database if exists zabbix_server;'" |
| 31 | + fi |
45 | 32 | SHELL |
46 | | - |
47 | | - apply_manifest(cleanup_puppet) |
48 | | - shell(cleanup_script) |
49 | 33 | end |
0 commit comments