ensure proper version of python3-influxdb is installed prior to running the states that require it

This commit is contained in:
m0duspwnens
2021-04-30 11:10:31 -04:00
parent d475e50bef
commit e32ca284c5
2 changed files with 9 additions and 2 deletions

View File

@@ -7,6 +7,9 @@
{% set IMAGEREPO = salt['pillar.get']('global:imagerepo') %} {% set IMAGEREPO = salt['pillar.get']('global:imagerepo') %}
{% import_yaml 'influxdb/defaults.yaml' as default_settings %} {% import_yaml 'influxdb/defaults.yaml' as default_settings %}
{% set influxdb = salt['grains.filter_by'](default_settings, default='influxdb', merge=salt['pillar.get']('influxdb', {})) %} {% set influxdb = salt['grains.filter_by'](default_settings, default='influxdb', merge=salt['pillar.get']('influxdb', {})) %}
{% from 'salt/map.jinja' import PYTHON3INFLUX with context %}
{% set PYTHONINFLUXVERSION = PYTHON3INFLUX.split("==")[1] | trim %}
{% set PYTHONINFLUXVERSIONINSTALLED = salt['cmd.run']("python3 -c 'import influxdb; print (influxdb.__version__)'", python_shell=True) | trim %}
{% if grains['role'] in ['so-manager', 'so-managersearch', 'so-eval', 'so-standalone'] and GRAFANA == 1 %} {% if grains['role'] in ['so-manager', 'so-managersearch', 'so-eval', 'so-standalone'] and GRAFANA == 1 %}
@@ -63,6 +66,8 @@ append_so-influxdb_so-status.conf:
- name: /opt/so/conf/so-status/so-status.conf - name: /opt/so/conf/so-status/so-status.conf
- text: so-influxdb - text: so-influxdb
# We have to make sure the influxdb module is the right version prior to state run since reload_modules is bugged
{% if PYTHONINFLUXVERSIONINSTALLED == PYTHONINFLUXVERSION %}
wait_for_influxdb: wait_for_influxdb:
http.query: http.query:
- name: 'https://{{MANAGER}}:8086/query?q=SHOW+DATABASES' - name: 'https://{{MANAGER}}:8086/query?q=SHOW+DATABASES'
@@ -124,6 +129,7 @@ so_downsample_cq:
- sls: salt.python3-influxdb - sls: salt.python3-influxdb
{% endfor %} {% endfor %}
{% endif %}
{% endif %} {% endif %}
{% else %} {% else %}

View File

@@ -33,11 +33,12 @@ influxdb_retention_policy.present_patch:
- {{PYTHONINSTALLER}}: python3_influxdb - {{PYTHONINSTALLER}}: python3_influxdb
- pkg: patch_package - pkg: patch_package
# We should be able to set reload_modules: True in this state in order to tell salt to reload its python modules due to us possibly installing
# and possibly modifying modules in this state. This is bugged according to https://github.com/saltstack/salt/issues/24925
influxdbmod.py_shard_duration_patch: influxdbmod.py_shard_duration_patch:
file.patch: file.patch:
- name: {{ SALT_MODULE_CODE_PATH }}/influxdbmod.py - name: {{ SALT_MODULE_CODE_PATH }}/influxdbmod.py
- source: salt://salt/files/influxdbmod.py.patch - source: salt://salt/files/influxdbmod.py.patch
- require: - require:
- {{PYTHONINSTALLER}}: python3_influxdb - {{PYTHONINSTALLER}}: python3_influxdb
- pkg: patch_package - pkg: patch_package
- reload_modules: True