Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions roles/graylog_datanode/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@

- name: 'Get Graylog Data Node version'
ansible.builtin.set_fact:
graylog_datanode__installed_version: '{{ ansible_facts["packages"]["graylog-datanode"][0]["version"] | regex_replace("\.\d+$", "") }}'
# keep major.minor only. the version is `7.2.1` on the Red Hat family, but carries the
# Debian revision on Debian and Ubuntu (`7.2.1-1`), and the minor version can have two digits
graylog_datanode__installed_version: '{{ ansible_facts["packages"]["graylog-datanode"][0]["version"] | regex_search("^\d+\.\d+") }}'

# the same slice the template src below uses, so the assert matches what is looked up
# the same value the template src below uses, so the assert matches what is looked up
- name: 'Assert that a configuration template for the installed Graylog Data Node version exists'
ansible.builtin.assert:
that:
- 'graylog_datanode__installed_version[:3] in __graylog_datanode__supported_versions'
- 'graylog_datanode__installed_version in __graylog_datanode__supported_versions'
quiet: true
fail_msg: 'Graylog Data Node {{ graylog_datanode__installed_version[:3] }} is not supported by this role. Supported versions: {{ __graylog_datanode__supported_versions | join(", ") }}.'
fail_msg: 'Graylog Data Node {{ graylog_datanode__installed_version }} is not supported by this role. Supported versions: {{ __graylog_datanode__supported_versions | join(", ") }}.'

- name: 'Deploy /etc/graylog/datanode/datanode.conf (version: {{ graylog_datanode__installed_version[:3] }})'
- name: 'Deploy /etc/graylog/datanode/datanode.conf (version: {{ graylog_datanode__installed_version }})'
ansible.builtin.template:
backup: true
src: 'etc/graylog/datanode/{{ graylog_datanode__installed_version[:3] }}-datanode.conf.j2'
src: 'etc/graylog/datanode/{{ graylog_datanode__installed_version }}-datanode.conf.j2'
dest: '/etc/graylog/datanode/datanode.conf'
owner: 'root'
group: 'root'
Expand Down
14 changes: 8 additions & 6 deletions roles/graylog_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@

- name: 'Get Graylog version'
ansible.builtin.set_fact:
graylog_server__installed_version: '{{ ansible_facts["packages"]["graylog-server"][0]["version"] | regex_replace("\.\d+$", "") }}'
# keep major.minor only. the version is `7.2.1` on the Red Hat family, but carries the
# Debian revision on Debian and Ubuntu (`7.2.1-1`), and the minor version can have two digits
graylog_server__installed_version: '{{ ansible_facts["packages"]["graylog-server"][0]["version"] | regex_search("^\d+\.\d+") }}'

# the same slice the template src below uses, so the assert matches what is looked up
# the same value the template src below uses, so the assert matches what is looked up
- name: 'Assert that a configuration template for the installed Graylog version exists'
ansible.builtin.assert:
that:
- 'graylog_server__installed_version[:3] in __graylog_server__supported_versions'
- 'graylog_server__installed_version in __graylog_server__supported_versions'
quiet: true
fail_msg: 'Graylog {{ graylog_server__installed_version[:3] }} is not supported by this role. Supported versions: {{ __graylog_server__supported_versions | join(", ") }}.'
fail_msg: 'Graylog {{ graylog_server__installed_version }} is not supported by this role. Supported versions: {{ __graylog_server__supported_versions | join(", ") }}.'

- name: 'Deploy /etc/graylog/server/server.conf (version: {{ graylog_server__installed_version[:3] }})'
- name: 'Deploy /etc/graylog/server/server.conf (version: {{ graylog_server__installed_version }})'
ansible.builtin.template:
backup: true
src: 'etc/graylog/server/{{ graylog_server__installed_version[:3] }}-server.conf.j2'
src: 'etc/graylog/server/{{ graylog_server__installed_version }}-server.conf.j2'
dest: '/etc/graylog/server/server.conf'
owner: 'graylog'
group: 'graylog'
Expand Down
3 changes: 2 additions & 1 deletion roles/mongodb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@

- name: 'Get mongodb-org-server version'
ansible.builtin.set_fact:
mongodb__installed_version: '{{ ansible_facts["packages"]["mongodb-org-server"][0]["version"] | regex_replace("\.\d+$", "") }}' # strip the patch version
# keep major.minor only, also if a package version ever carries a Debian revision (`8.0.4-1`)
mongodb__installed_version: '{{ ansible_facts["packages"]["mongodb-org-server"][0]["version"] | regex_search("^\d+\.\d+") }}'

# the template name carries the OS family, so the supported versions are per family too
- name: 'Assert that a configuration template for the installed MongoDB version exists'
Expand Down
13 changes: 7 additions & 6 deletions roles/opensearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
ansible.builtin.package_facts: # yamllint disable-line rule:empty-values
check_mode: false # run task even if `--check` is specified

- name: 'Get installed OpenSearch version'
- name: 'Get installed OpenSearch major version'
ansible.builtin.set_fact:
__opensearch__installed_version: '{{ ansible_facts["packages"]["opensearch"][0]["version"] | regex_replace("\.\d+$", "") }}'
# all digits up to the first dot, so a major version 10 and above stays intact
__opensearch__installed_major: '{{ ansible_facts["packages"]["opensearch"][0]["version"] | regex_search("^\d+") }}'

# only the major selects the template, so the assert matches on the same expression
- name: 'Assert that a configuration template for the installed OpenSearch version exists'
ansible.builtin.assert:
that:
- '__opensearch__installed_version[:1] ~ ".x" in __opensearch__supported_versions'
- '__opensearch__installed_major ~ ".x" in __opensearch__supported_versions'
quiet: true
fail_msg: 'OpenSearch {{ __opensearch__installed_version[:1] }}.x is not supported by this role. Supported versions: {{ __opensearch__supported_versions | join(", ") }}.'
fail_msg: 'OpenSearch {{ __opensearch__installed_major }}.x is not supported by this role. Supported versions: {{ __opensearch__supported_versions | join(", ") }}.'

- name: 'Deploy /etc/opensearch/{{ __opensearch__installed_version[:1] }}.x-opensearch.yml'
- name: 'Deploy /etc/opensearch/{{ __opensearch__installed_major }}.x-opensearch.yml'
ansible.builtin.template:
backup: true
src: 'etc/opensearch/{{ __opensearch__installed_version[:1] }}.x-opensearch.yml.j2'
src: 'etc/opensearch/{{ __opensearch__installed_major }}.x-opensearch.yml.j2'
dest: '/etc/opensearch/opensearch.yml'
owner: 'opensearch'
group: 'opensearch'
Expand Down
Loading