saltstack-formulas / zabbix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
50 stars 121 forks source link

Add suse support (with mysql defaults this time) #146

Closed ghormoon closed 3 years ago

ghormoon commented 3 years ago

PR progress checklist (to be filled in by reviewers)

What type of PR is this?

Primary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Replaces https://github.com/saltstack-formulas/zabbix-formula/pull/140

Describe the changes you're proposing

Following up on my colleagues work from https://github.com/saltstack-formulas/zabbix-formula/pull/140 i made adjustments to the defaults to go with mysql as you prefer. Please let me know if there are any other issues i did not address properly.

myii commented 3 years ago

@ghormoon After applying the fixes mentioned above, the good news is that this is almost passing on openSUSE Leap but will need some more work on openSUSE Tumbleweed:

hatifnatt commented 3 years ago
* https://gitlab.com/myii/zabbix-formula/-/jobs/1186140109

  * Repo URL would need adjusting.

That's because Tumbleweed grains['osmajorrelease'] != SLES grains['osmajorrelease'] (at least I think so, can't verify).

@ghormoon are you using openSUSE Tumbleweed or SLES?

ghormoon commented 3 years ago

I'm using SLES 15, but honestly i didn't run the kitchen test, i just tried it manually :) the problem is not sles vs opensuse, but the version number. if you look on the log, it shows https://repo.zabbix.com/zabbix/4.4/sles/20210414/x86_64/

my link is https://repo.zabbix.com/zabbix/5.2/sles/15/x86_64/ on my SLES 15 VM (the 5.2 is because of variable), so the problem is the tumbleweed versioning. Either we can somehow hack it around if version>15 then version = 15, but the question is, if we want to run it on tumbleweed, as zabbix doesn't have repo for that. 99% the sles 15 repo will work, though.

leap is much closer to sles, so it makes sense to fix the path for files expected in tests

i'll have a look on the suggestions and try to apply and test them locally on sles, i just got to it and you're quite active :)

myii commented 3 years ago

That's because Tumbleweed grains['osmajorrelease'] != SLES grains['osmajorrelease'] (at least I think so, can't verify).

@hatifnatt @ghormoon I've tried a quick fix locally (using Kitchen) and there's deeper issues with Tumbleweed, for example:

       [INFO    ] Executing state pkg.installed for [zabbix-server]
       [DEBUG   ] Could not LazyLoad pkg.check_db: 'pkg.check_db' is not available.
       [DEBUG   ] targeting package: zabbix-server-mysql
       [DEBUG   ] Calling Zypper: systemd-run --scope zypper --non-interactive --no-refresh --no-refresh install --auto-agree-with-licenses --name zabbix-server-mysql
       [INFO    ] Executing command ['systemd-run', '--scope', 'zypper', '--non-interactive', '--no-refresh', '--no-refresh', 'install', '--auto-agree-with-licenses', '--name', 'zabbix-server-mysql'] in directory '/root'
       [ERROR   ] Command '['systemd-run', '--scope', 'zypper', '--non-interactive', '--no-refresh', '--no-refresh', 'install', '--auto-agree-with-licenses', '--name', 'zabbix-server-mysql']' failed with return code: 4
       [ERROR   ] stdout: Warning: The flag --no-refresh can only be used once.
       Loading repository data...
       Reading installed packages...
       Resolving package dependencies...

       Problem: nothing provides libevent-2.1.so.6()(64bit) needed by zabbix-server-mysql-4.4.10-1.el15.x86_64
        Solution 1: do not install zabbix-server-mysql-4.4.10-1.el15.x86_64
        Solution 2: break zabbix-server-mysql-4.4.10-1.el15.x86_64 by ignoring some of its dependencies

       Choose from above solutions by number or cancel [1/2/c/d/?] (c): c
       [ERROR   ] stderr: Running scope as unit: run-r0a507cfdfb0f48a7bca8fd3fdc509a86.scope
       [ERROR   ] retcode: 4
       [ERROR   ] An error was encountered while installing package(s): Zypper command failure: Running scope as unit: run-r0a507cfdfb0f48a7bca8fd3fdc509a86.scope

So let's not worry about Tumbleweed for now and just get Leap-15 up and running. In fact, I'll just fix the test and push the fixes here and then this PR can be merged.

myii commented 3 years ago

Just for reference, this was the fix I was going to suggest (but not going to apply now):

{%- elif salt['grains.get']('os_family') == 'Suse' %}
{#-   TODO: When the v5 `map.jinja` is introduced to this formula, this should be provided via. the relevant `oscodename` parameter file #}
{%-   set majorrelease = '15' if grains.get('oscodename', '') == 'openSUSE Tumbleweed' else grains['osmajorrelease'] %}
{{ id_prefix }}_repo:
  pkgrepo.managed:
    - name: zabbix
    - humanname: "Zabbix Official Repository"
    - baseurl: https://repo.zabbix.com/zabbix/{{ zabbix.version_repo }}/sles/{{ majorrelease }}/x86_64/
    - gpgcheck: 1
    - gpgkey: https://repo.zabbix.com/zabbix/{{ zabbix.version_repo }}/sles/{{ majorrelease }}/x86_64/repodata/repomd.xml.key
    - gpgautoimport: True
ghormoon commented 3 years ago

yeah, it would be asking for dependency problems like you have in the log sooner or later. even if we were lucky now and it passed, we might get and bug reported in a month or two, so i'd stick to that only leap/sles is supported. hacking it around like this is like using debian 10 packages on testing/experimental. it might work, but the further it diverges, the higher is the chance of issues

myii commented 3 years ago

@ghormoon OK, here's the final bit then, to get Leap-15 passing in GitLab CI:

https://github.com/saltstack-formulas/zabbix-formula/blob/2c67b11ce1b0ef4442a0d3dd1ec7bd3e7fb500ef/test/integration/default/controls/config_spec.rb#L41-L48

Please add the suse block as follows:

  case platform[:family]
  when 'debian'
    server_file_group = 'root'
    server_file_mode = '0644'
    setting_dbsocket = '/var/run/mysqld/mysqld.sock'
  when 'fedora'
    server_file_group = 'zabbixsrv'
  when 'suse'
    setting_dbsocket = '/run/mysql/mysql.sock'
  end

Then this PR should be ready for merging.

Would you prefer to do it or shall I push all of the changes myself?

ghormoon commented 3 years ago

ok, i tried to apply the changes and allowing leap on ci, we'll see if it passes now :) thanks for the help so far

myii commented 3 years ago

Thanks, @ghormoon -- all working nicely. @hatifnatt I went ahead and merged, since you already had got your approval in -- I wouldn't usually get involved when there's a codeowner available, so please don't think you have to wait for me!

saltstack-formulas-travis commented 3 years ago

:tada: This PR is included in version 1.1.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: