From 6a92b3cf9077e3d9675c5fb70f185552e5011948 Mon Sep 17 00:00:00 2001 From: Bodo Schulz Date: Tue, 12 Nov 2024 09:11:02 +0100 Subject: [PATCH 1/3] support loki v3.x --- plugins/modules/loki_verify_config.py | 142 ++++++++++++++++ roles/dashboards/vars/redhat.yml | 3 - roles/grafana/defaults/main.yml | 2 +- roles/loki/defaults/main.yml | 2 +- roles/loki/docs/storage.md | 8 + roles/loki/handlers/main.yml | 18 +- roles/loki/molecule/2.7/converge.yml | 9 + .../loki/molecule/2.7/group_vars/all/vars.yml | 9 + roles/loki/molecule/2.7/molecule.yml | 55 +++++++ roles/loki/molecule/2.7/prepare.yml | 51 ++++++ roles/loki/molecule/2.7/tests/test_default.py | 154 ++++++++++++++++++ roles/loki/molecule/3.2/converge.yml | 9 + .../loki/molecule/3.2/group_vars/all/vars.yml | 27 +++ roles/loki/molecule/3.2/molecule.yml | 55 +++++++ roles/loki/molecule/3.2/prepare.yml | 51 ++++++ roles/loki/molecule/3.2/tests/test_default.py | 154 ++++++++++++++++++ roles/loki/tasks/download/main.yml | 12 +- roles/loki/tasks/service.yml | 6 + .../templates/loki/loki.d/storage_config.j2 | 55 +++++++ roles/loki/vars/main.yml | 9 +- roles/loki/vars/redhat.yml | 8 - roles/loki/vars/rocky.yml | 8 - roles/promtail/defaults/main.yml | 2 +- roles/promtail/vars/redhat.yml | 8 - 24 files changed, 814 insertions(+), 43 deletions(-) create mode 100644 plugins/modules/loki_verify_config.py delete mode 100644 roles/dashboards/vars/redhat.yml create mode 100644 roles/loki/molecule/2.7/converge.yml create mode 100644 roles/loki/molecule/2.7/group_vars/all/vars.yml create mode 100644 roles/loki/molecule/2.7/molecule.yml create mode 100644 roles/loki/molecule/2.7/prepare.yml create mode 100644 roles/loki/molecule/2.7/tests/test_default.py create mode 100644 roles/loki/molecule/3.2/converge.yml create mode 100644 roles/loki/molecule/3.2/group_vars/all/vars.yml create mode 100644 roles/loki/molecule/3.2/molecule.yml create mode 100644 roles/loki/molecule/3.2/prepare.yml create mode 100644 roles/loki/molecule/3.2/tests/test_default.py delete mode 100644 roles/loki/vars/redhat.yml delete mode 100644 roles/loki/vars/rocky.yml delete mode 100644 roles/promtail/vars/redhat.yml diff --git a/plugins/modules/loki_verify_config.py b/plugins/modules/loki_verify_config.py new file mode 100644 index 0000000..0179332 --- /dev/null +++ b/plugins/modules/loki_verify_config.py @@ -0,0 +1,142 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +# (c) 2022, Bodo Schulz + +from __future__ import absolute_import, division, print_function +from ansible.module_utils.basic import AnsibleModule + +# import os +# from requests.exceptions import ConnectionError +import json +# import requests +# from pathlib import Path + +# --------------------------------------------------------------------------------------- + +DOCUMENTATION = """ +module: loki_verify_config +version_added: 1.1.0 +author: "Bodo Schulz (@bodsch) " + +short_description: TBD + +description: + - TBD +""" + +EXAMPLES = """ +""" + +RETURN = """ +""" + +# --------------------------------------------------------------------------------------- + + +class LokiVerifyConfig(object): + + def __init__(self, module): + """ + """ + self.module = module + + self.log_level = module.params.get("log_level") + self.config_file = module.params.get("config_file") + + self._loki_cli = module.get_bin_path("loki", True) + + def run(self): + """ + /usr/bin/loki -verify-config -log.format json -log.level debug -config.file /etc/loki/loki.yml + """ + result = dict( + rc=0, + failed=False, + changed=False, + msg="Loki verify config ..." + ) + + _failed = True + + args = [] + + args.append(self._loki_cli) + args.append("-verify-config") + + args.append("-log.format") + args.append("json") + + if self.log_level: + args.append("-log.level") + args.append(self.log_level) + + if self.config_file: + args.append("-config.file") + args.append(self.config_file) + + rc, out, err = self.__exec(args, check_rc=False) + + if rc == 0: + _failed = False + + if isinstance(err, str): + err = json.loads(err) + + if isinstance(err, dict): + error_msg = err.get("err", None) + msg = err.get("msg", None) + + if rc != 0 and error_msg: + msg = error_msg.split("\n") + else: + msg = err + + result = dict( + failed = _failed, + changed = False, + cmd=" ".join(args), + msg = msg + ) + + return result + + def __exec(self, commands, check_rc=True): + """ + """ + rc, out, err = self.module.run_command(commands, check_rc=check_rc) + # self.module.log(msg=f" rc : '{rc}'") + # self.module.log(msg=f" out: '{out}'") + # self.module.log(msg=f" err: '{err}'") + return rc, out, err + + +def main(): + """ + """ + specs = dict( + log_level=dict( + default="info", + choices=["debug", "info", "warn", "error"] + ), + config_file=dict( + default="/etc/loki/loki.yml", + type="str", + ), + ) + + module = AnsibleModule( + argument_spec=specs, + supports_check_mode=False, + ) + + o = LokiVerifyConfig(module) + result = o.run() + + module.log(msg=f"= result: {result}") + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/roles/dashboards/vars/redhat.yml b/roles/dashboards/vars/redhat.yml deleted file mode 100644 index c81cf5b..0000000 --- a/roles/dashboards/vars/redhat.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -... diff --git a/roles/grafana/defaults/main.yml b/roles/grafana/defaults/main.yml index b0ab5f6..20922a9 100644 --- a/roles/grafana/defaults/main.yml +++ b/roles/grafana/defaults/main.yml @@ -1,6 +1,6 @@ --- -grafana_version: 9.4.7 +grafana_version: 11.3.0 grafana_scm: use_tags: true diff --git a/roles/loki/defaults/main.yml b/roles/loki/defaults/main.yml index 4c1a34d..2dd40dc 100644 --- a/roles/loki/defaults/main.yml +++ b/roles/loki/defaults/main.yml @@ -1,6 +1,6 @@ --- -loki_version: "2.7.2" +loki_version: "3.2.1" loki_scm: use_tags: true diff --git a/roles/loki/docs/storage.md b/roles/loki/docs/storage.md index 8afbd5e..964253d 100644 --- a/roles/loki/docs/storage.md +++ b/roles/loki/docs/storage.md @@ -12,6 +12,7 @@ see also: - [gcs storage](https://grafana.com/docs/loki/latest/configuration/#gcs_storage_config) - [s3 storage](https://grafana.com/docs/loki/latest/configuration/#s3_storage_config) - [swift storage](https://grafana.com/docs/loki/latest/configuration/#swift_storage_config) +- [tsdb_storage](https://grafana.com/docs/loki/latest/configure/#storage_config) Configures a (local) file system as a general storage for different data generated by Loki. @@ -29,4 +30,11 @@ loki_config_storage: directory: "{{ loki_storage_dir }}/index" filesystem: directory: "{{ loki_storage_dir }}/chunks" + tsdb_shipper: + active_index_directory: "{{ loki_storage_dir }}/tsdb-index" + cache_location: "{{ loki_storage_dir }}/tsdb-cache" + cache_ttl: "" + resync_interval: "" + query_ready_num_days: "" + index_gateway_client: {} ``` diff --git a/roles/loki/handlers/main.yml b/roles/loki/handlers/main.yml index 8af75be..9438d1d 100644 --- a/roles/loki/handlers/main.yml +++ b/roles/loki/handlers/main.yml @@ -8,13 +8,19 @@ when: - ansible_service_mgr | lower == "systemd" -- name: verify config # noqa no-changed-when +- name: verify config become: true - ansible.builtin.command: | - loki \ - -verify-config \ - -log.level debug \ - -config.file {{ loki_config_dir }}/loki.yml + bodsch.grafana.loki_verify_config: + log_level: debug + config_file: "{{ loki_config_dir }}/loki.yml" + +# - name: verify config # noqa no-changed-when +# become: true +# ansible.builtin.command: | +# loki \ +# -verify-config \ +# -log.level debug \ +# -config.file {{ loki_config_dir }}/loki.yml - name: restart loki become: true diff --git a/roles/loki/molecule/2.7/converge.yml b/roles/loki/molecule/2.7/converge.yml new file mode 100644 index 0000000..7e31ee7 --- /dev/null +++ b/roles/loki/molecule/2.7/converge.yml @@ -0,0 +1,9 @@ +--- + +- name: converge + hosts: instance + any_errors_fatal: false + become: false + + roles: + - role: bodsch.grafana.loki diff --git a/roles/loki/molecule/2.7/group_vars/all/vars.yml b/roles/loki/molecule/2.7/group_vars/all/vars.yml new file mode 100644 index 0000000..cd5c50a --- /dev/null +++ b/roles/loki/molecule/2.7/group_vars/all/vars.yml @@ -0,0 +1,9 @@ +--- + +loki_version: "2.6.1" + +loki_config_server: + http_listen_address: "127.0.0.1" + http_listen_port: 3100 + +... diff --git a/roles/loki/molecule/2.7/molecule.yml b/roles/loki/molecule/2.7/molecule.yml new file mode 100644 index 0000000..62e7bbe --- /dev/null +++ b/roles/loki/molecule/2.7/molecule.yml @@ -0,0 +1,55 @@ +--- + +role_name_check: 1 + +dependency: + name: galaxy + +driver: + name: docker + +platforms: + - name: instance + image: "bodsch/ansible-${DISTRIBUTION:-debian:12}" + command: ${MOLECULE_DOCKER_COMMAND:-""} + docker_host: "${DOCKER_HOST:-unix://run/docker.sock}" + privileged: true + pre_build_image: true + cgroupns_mode: host + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + - /var/lib/containerd + capabilities: + - SYS_ADMIN + tmpfs: + - /run + - /tmp + +provisioner: + name: ansible + ansible_args: + - --diff + - -v + config_options: + defaults: + deprecation_warnings: true + stdout_callback: yaml + callbacks_enabled: profile_tasks + gathering: smart + fact_caching: jsonfile + fact_caching_timeout: 8640 + fact_caching_connection: ansible_facts + +scenario: + test_sequence: + - destroy + - dependency + - syntax + - create + - prepare + - converge + - verify + - destroy + +verifier: + name: testinfra diff --git a/roles/loki/molecule/2.7/prepare.yml b/roles/loki/molecule/2.7/prepare.yml new file mode 100644 index 0000000..8233ae5 --- /dev/null +++ b/roles/loki/molecule/2.7/prepare.yml @@ -0,0 +1,51 @@ +--- + +- name: information + hosts: all + gather_facts: true + + pre_tasks: + - name: arch- / artixlinux + when: + - ansible_distribution | lower == 'archlinux' or + ansible_os_family | lower == 'artix linux' + block: + - name: update pacman system + ansible.builtin.command: | + pacman --refresh --sync --sysupgrade --noconfirm + register: pacman + changed_when: pacman.rc != 0 + failed_when: pacman.rc != 0 + + - name: create depends service + ansible.builtin.copy: + mode: 0755 + dest: /etc/init.d/net + content: | + #!/usr/bin/openrc-run + true + when: + - ansible_os_family | lower == 'artix linux' + + - name: make sure python3-apt is installed (only debian based) + ansible.builtin.package: + name: + - python3-apt + state: present + when: + - ansible_os_family | lower == 'debian' + + - name: update package cache + become: true + ansible.builtin.package: + update_cache: true + + - name: environment + ansible.builtin.debug: + msg: + - "os family : {{ ansible_distribution }} ({{ ansible_os_family }})" + - "distribution version : {{ ansible_distribution_major_version }}" + - "ansible version : {{ ansible_version.full }}" + - "python version : {{ ansible_python.version.major }}.{{ ansible_python.version.minor }}" + +... diff --git a/roles/loki/molecule/2.7/tests/test_default.py b/roles/loki/molecule/2.7/tests/test_default.py new file mode 100644 index 0000000..9bd751c --- /dev/null +++ b/roles/loki/molecule/2.7/tests/test_default.py @@ -0,0 +1,154 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from ansible.parsing.dataloader import DataLoader +from ansible.template import Templar + +import json +import pytest +import os + +import testinfra.utils.ansible_runner + +HOST = 'instance' + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(HOST) + + +def pp_json(json_thing, sort=True, indents=2): + if type(json_thing) is str: + print(json.dumps(json.loads(json_thing), sort_keys=sort, indent=indents)) + else: + print(json.dumps(json_thing, sort_keys=sort, indent=indents)) + return None + + +def base_directory(): + """ ... """ + cwd = os.getcwd() + + if ('group_vars' in os.listdir(cwd)): + directory = "../.." + molecule_directory = "." + else: + directory = "." + molecule_directory = "molecule/{}".format(os.environ.get('MOLECULE_SCENARIO_NAME')) + + return directory, molecule_directory + + +def read_ansible_yaml(file_name, role_name): + ext_arr = ["yml", "yaml"] + + read_file = None + + for e in ext_arr: + test_file = "{}.{}".format(file_name, e) + if os.path.isfile(test_file): + read_file = test_file + break + + return "file={} name={}".format(read_file, role_name) + + +@pytest.fixture() +def get_vars(host): + """ + parse ansible variables + - defaults/main.yml + - vars/main.yml + - vars/${DISTRIBUTION}.yaml + - molecule/${MOLECULE_SCENARIO_NAME}/group_vars/all/vars.yml + """ + base_dir, molecule_dir = base_directory() + distribution = host.system_info.distribution + + if distribution in ['debian', 'ubuntu']: + os = "debian" + elif distribution in ['redhat', 'ol', 'centos', 'rocky', 'almalinux']: + os = "redhat" + elif distribution in ['arch']: + os = "archlinux" + + # print(" -> {} / {}".format(distribution, os)) + # print(" -> {}".format(base_dir)) + + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") + + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") + + ansible_vars = defaults_vars + ansible_vars.update(vars_vars) + ansible_vars.update(distibution_vars) + ansible_vars.update(molecule_vars) + # ansible_vars.update(host_vars) + + templar = Templar(loader=DataLoader(), variables=ansible_vars) + result = templar.template(ansible_vars, fail_on_undefined=False) + + return result + + +def test_package(host, get_vars): + """ + """ + packages = get_vars.get("loki_packages") + install_path = get_vars.get("loki_install_path") + + for pack in packages: + f = host.file("{}/{}".format(install_path, pack)) + assert f.exists + assert f.is_file + + +@pytest.mark.parametrize("dirs", [ + "/etc/loki", +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/etc/loki/loki.yml" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_user(host): + assert host.group("loki").exists + assert host.user("loki").exists + assert "loki" in host.user("loki").groups + assert host.user("loki").home == "/nonexistent" + + +def test_service(host, get_vars): + service = host.service("loki") + assert service.is_enabled + assert service.is_running + + +def test_open_port(host, get_vars): + for i in host.socket.get_listening_sockets(): + print(i) + + loki_server = get_vars.get("loki_config_server") + + address = loki_server.get("http_listen_address") + port = loki_server.get("http_listen_port") + + service = host.socket(f"tcp://{address}:{port}") + assert service.is_listening diff --git a/roles/loki/molecule/3.2/converge.yml b/roles/loki/molecule/3.2/converge.yml new file mode 100644 index 0000000..7e31ee7 --- /dev/null +++ b/roles/loki/molecule/3.2/converge.yml @@ -0,0 +1,9 @@ +--- + +- name: converge + hosts: instance + any_errors_fatal: false + become: false + + roles: + - role: bodsch.grafana.loki diff --git a/roles/loki/molecule/3.2/group_vars/all/vars.yml b/roles/loki/molecule/3.2/group_vars/all/vars.yml new file mode 100644 index 0000000..4f68e92 --- /dev/null +++ b/roles/loki/molecule/3.2/group_vars/all/vars.yml @@ -0,0 +1,27 @@ +--- + +loki_version: "3.2.1" + +loki_config_server: + http_listen_address: "127.0.0.1" + http_listen_port: 3100 + +loki_config_schema: + configs: + - from: "2024-01-01" + store: tsdb # tsdb # + object_store: filesystem + schema: v13 # v13 # + index: + prefix: index_ + period: 24h # 24h # + chunks: + prefix: index_ + period: 24h + row_shards: 16 + +limits_config: + allow_structured_metadata: false + +... + diff --git a/roles/loki/molecule/3.2/molecule.yml b/roles/loki/molecule/3.2/molecule.yml new file mode 100644 index 0000000..62e7bbe --- /dev/null +++ b/roles/loki/molecule/3.2/molecule.yml @@ -0,0 +1,55 @@ +--- + +role_name_check: 1 + +dependency: + name: galaxy + +driver: + name: docker + +platforms: + - name: instance + image: "bodsch/ansible-${DISTRIBUTION:-debian:12}" + command: ${MOLECULE_DOCKER_COMMAND:-""} + docker_host: "${DOCKER_HOST:-unix://run/docker.sock}" + privileged: true + pre_build_image: true + cgroupns_mode: host + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + - /var/lib/containerd + capabilities: + - SYS_ADMIN + tmpfs: + - /run + - /tmp + +provisioner: + name: ansible + ansible_args: + - --diff + - -v + config_options: + defaults: + deprecation_warnings: true + stdout_callback: yaml + callbacks_enabled: profile_tasks + gathering: smart + fact_caching: jsonfile + fact_caching_timeout: 8640 + fact_caching_connection: ansible_facts + +scenario: + test_sequence: + - destroy + - dependency + - syntax + - create + - prepare + - converge + - verify + - destroy + +verifier: + name: testinfra diff --git a/roles/loki/molecule/3.2/prepare.yml b/roles/loki/molecule/3.2/prepare.yml new file mode 100644 index 0000000..8233ae5 --- /dev/null +++ b/roles/loki/molecule/3.2/prepare.yml @@ -0,0 +1,51 @@ +--- + +- name: information + hosts: all + gather_facts: true + + pre_tasks: + - name: arch- / artixlinux + when: + - ansible_distribution | lower == 'archlinux' or + ansible_os_family | lower == 'artix linux' + block: + - name: update pacman system + ansible.builtin.command: | + pacman --refresh --sync --sysupgrade --noconfirm + register: pacman + changed_when: pacman.rc != 0 + failed_when: pacman.rc != 0 + + - name: create depends service + ansible.builtin.copy: + mode: 0755 + dest: /etc/init.d/net + content: | + #!/usr/bin/openrc-run + true + when: + - ansible_os_family | lower == 'artix linux' + + - name: make sure python3-apt is installed (only debian based) + ansible.builtin.package: + name: + - python3-apt + state: present + when: + - ansible_os_family | lower == 'debian' + + - name: update package cache + become: true + ansible.builtin.package: + update_cache: true + + - name: environment + ansible.builtin.debug: + msg: + - "os family : {{ ansible_distribution }} ({{ ansible_os_family }})" + - "distribution version : {{ ansible_distribution_major_version }}" + - "ansible version : {{ ansible_version.full }}" + - "python version : {{ ansible_python.version.major }}.{{ ansible_python.version.minor }}" + +... diff --git a/roles/loki/molecule/3.2/tests/test_default.py b/roles/loki/molecule/3.2/tests/test_default.py new file mode 100644 index 0000000..9bd751c --- /dev/null +++ b/roles/loki/molecule/3.2/tests/test_default.py @@ -0,0 +1,154 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from ansible.parsing.dataloader import DataLoader +from ansible.template import Templar + +import json +import pytest +import os + +import testinfra.utils.ansible_runner + +HOST = 'instance' + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(HOST) + + +def pp_json(json_thing, sort=True, indents=2): + if type(json_thing) is str: + print(json.dumps(json.loads(json_thing), sort_keys=sort, indent=indents)) + else: + print(json.dumps(json_thing, sort_keys=sort, indent=indents)) + return None + + +def base_directory(): + """ ... """ + cwd = os.getcwd() + + if ('group_vars' in os.listdir(cwd)): + directory = "../.." + molecule_directory = "." + else: + directory = "." + molecule_directory = "molecule/{}".format(os.environ.get('MOLECULE_SCENARIO_NAME')) + + return directory, molecule_directory + + +def read_ansible_yaml(file_name, role_name): + ext_arr = ["yml", "yaml"] + + read_file = None + + for e in ext_arr: + test_file = "{}.{}".format(file_name, e) + if os.path.isfile(test_file): + read_file = test_file + break + + return "file={} name={}".format(read_file, role_name) + + +@pytest.fixture() +def get_vars(host): + """ + parse ansible variables + - defaults/main.yml + - vars/main.yml + - vars/${DISTRIBUTION}.yaml + - molecule/${MOLECULE_SCENARIO_NAME}/group_vars/all/vars.yml + """ + base_dir, molecule_dir = base_directory() + distribution = host.system_info.distribution + + if distribution in ['debian', 'ubuntu']: + os = "debian" + elif distribution in ['redhat', 'ol', 'centos', 'rocky', 'almalinux']: + os = "redhat" + elif distribution in ['arch']: + os = "archlinux" + + # print(" -> {} / {}".format(distribution, os)) + # print(" -> {}".format(base_dir)) + + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") + + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") + + ansible_vars = defaults_vars + ansible_vars.update(vars_vars) + ansible_vars.update(distibution_vars) + ansible_vars.update(molecule_vars) + # ansible_vars.update(host_vars) + + templar = Templar(loader=DataLoader(), variables=ansible_vars) + result = templar.template(ansible_vars, fail_on_undefined=False) + + return result + + +def test_package(host, get_vars): + """ + """ + packages = get_vars.get("loki_packages") + install_path = get_vars.get("loki_install_path") + + for pack in packages: + f = host.file("{}/{}".format(install_path, pack)) + assert f.exists + assert f.is_file + + +@pytest.mark.parametrize("dirs", [ + "/etc/loki", +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/etc/loki/loki.yml" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_user(host): + assert host.group("loki").exists + assert host.user("loki").exists + assert "loki" in host.user("loki").groups + assert host.user("loki").home == "/nonexistent" + + +def test_service(host, get_vars): + service = host.service("loki") + assert service.is_enabled + assert service.is_running + + +def test_open_port(host, get_vars): + for i in host.socket.get_listening_sockets(): + print(i) + + loki_server = get_vars.get("loki_config_server") + + address = loki_server.get("http_listen_address") + port = loki_server.get("http_listen_port") + + service = host.socket(f"tcp://{address}:{port}") + assert service.is_listening diff --git a/roles/loki/tasks/download/main.yml b/roles/loki/tasks/download/main.yml index ec0e924..48eeb24 100644 --- a/roles/loki/tasks/download/main.yml +++ b/roles/loki/tasks/download/main.yml @@ -25,12 +25,12 @@ ansible.builtin.set_fact: loki_version: "{{ _latest_release.latest_release }}" -- name: assert loki version 3.x - ansible.builtin.assert: - that: - - loki_version is not version_compare("3.0", ">=") - msg: Loki version 3 is currently not supported! - quiet: true +# - name: assert loki version 3.x +# ansible.builtin.assert: +# that: +# - loki_version is not version_compare("3.0", ">=") +# msg: Loki version 3 is currently not supported! +# quiet: true - name: define download information ansible.builtin.set_fact: diff --git a/roles/loki/tasks/service.yml b/roles/loki/tasks/service.yml index cd754cc..2bfc4b3 100644 --- a/roles/loki/tasks/service.yml +++ b/roles/loki/tasks/service.yml @@ -3,6 +3,12 @@ - name: restart loki if needed ansible.builtin.meta: flush_handlers +- name: verify config + become: true + bodsch.grafana.loki_verify_config: + log_level: debug + config_file: "{{ loki_config_dir }}/loki.yml" + - name: ensure loki is enabled on boot become: true ansible.builtin.service: diff --git a/roles/loki/templates/loki/loki.d/storage_config.j2 b/roles/loki/templates/loki/loki.d/storage_config.j2 index 7f09149..39be163 100644 --- a/roles/loki/templates/loki/loki.d/storage_config.j2 +++ b/roles/loki/templates/loki/loki.d/storage_config.j2 @@ -193,6 +193,9 @@ storage_config: "resync_interval", "query_ready_num_days" ] -%} + {# + remove configurations for loki version >= 3 + #} {% if loki_main_version is version_compare("3.0", operator='>=') %} {% set indx = valid_keys.index('shared_store') %} {% set _ = valid_keys.pop(indx) %} @@ -231,6 +234,58 @@ storage_config: {% endif %} {% endif %} {% endif %} + {% if loki_config_storage.tsdb_shipper is defined and + loki_config_storage.tsdb_shipper | count > 0 %} + {% set valid_keys = [ + "active_index_directory", + "cache_location", + "cache_ttl", + "resync_interval", + "query_ready_num_days" + ] -%} + {# + {% if loki_main_version is version_compare("3.0", operator='>=') %} + {% set indx = valid_keys.index('shared_store') %} + {% set _ = valid_keys.pop(indx) %} + {% endif %} + #} + tsdb_shipper: + {% for key, v in loki_config_storage.tsdb_shipper.items() %} + {% if key in valid_keys %} + {% set value = v | bodsch.grafana.loki_value %} + {% if value %} + {{ key }}: {{ value }} + {% endif %} + {% endif %} + {% endfor %} + {% if loki_config_storage.tsdb_shipper.index_gateway_client is defined and + loki_config_storage.tsdb_shipper.index_gateway_client | count > 0 %} + {% set valid_keys = [ + "grpc_client_config", + "server_address", + "log_gateway_requests"] %} + {# + {% if loki_main_version is version_compare("2.5", operator='>') %} + {% set indx = valid_keys.index('log_gateway_requests') %} + {% set _ = valid_keys.pop(indx) %} + {% endif %} + #} + index_gateway_client: + {% for key, v in loki_config_querier.items() %} + {% if key in valid_keys %} + {% set value = v | bodsch.grafana.loki_value %} + {% if value %} + {{ key }}: {{ value }} + {% endif %} + {% endif %} + {% endfor %} + {% if loki_config_storage.tsdb_shipper.index_gateway_client.grpc_client_config is defined and + loki_config_storage.tsdb_shipper.index_gateway_client.grpc_client_config | count > 0 %} + grpc_client_config: + {{ tpl.makro_grpc_client_config(loki_config_storage.tsdb_shipper.index_gateway_client.grpc_client_config) | indent(8, False) }} + {% endif %} + {% endif %} + {% endif %} {% if loki_config_storage.filesystem is defined and loki_config_storage.filesystem | count > 0 %} filesystem: diff --git a/roles/loki/vars/main.yml b/roles/loki/vars/main.yml index 4979840..bfbc20d 100644 --- a/roles/loki/vars/main.yml +++ b/roles/loki/vars/main.yml @@ -170,6 +170,7 @@ loki_defaults_config_index_gateway: {} loki_defaults_config_frontend: {} loki_defaults_config_storage: + # https://grafana.com/docs/loki/latest/configure/#storage_config alibabacloud: {} azure: {} bos: {} @@ -209,7 +210,13 @@ loki_defaults_config_storage: max_chunk_batch_size: 50 index_queries_cache_config: {} congestion_control: {} - tsdb_shipper: {} + tsdb_shipper: + active_index_directory: "{{ loki_storage_dir }}/tsdb-index" + cache_location: "{{ loki_storage_dir }}/tsdb-cache" + cache_ttl: "" + resync_interval: "" + query_ready_num_days: "" + index_gateway_client: {} bloom_shipper: {} loki_defaults_config_chunk_store: {} diff --git a/roles/loki/vars/redhat.yml b/roles/loki/vars/redhat.yml deleted file mode 100644 index 662ae6d..0000000 --- a/roles/loki/vars/redhat.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -loki_requirements: - - iproute - -systemd_lib_directory: /usr/lib/systemd/system - -... diff --git a/roles/loki/vars/rocky.yml b/roles/loki/vars/rocky.yml deleted file mode 100644 index 662ae6d..0000000 --- a/roles/loki/vars/rocky.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -loki_requirements: - - iproute - -systemd_lib_directory: /usr/lib/systemd/system - -... diff --git a/roles/promtail/defaults/main.yml b/roles/promtail/defaults/main.yml index c87e192..37cc756 100644 --- a/roles/promtail/defaults/main.yml +++ b/roles/promtail/defaults/main.yml @@ -1,6 +1,6 @@ --- -promtail_version: "2.7.2" +promtail_version: "3.2.1" promtail_release: {} diff --git a/roles/promtail/vars/redhat.yml b/roles/promtail/vars/redhat.yml deleted file mode 100644 index ccb0354..0000000 --- a/roles/promtail/vars/redhat.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -promtail_requirements: - - iproute - -systemd_lib_directory: /usr/lib/systemd/system - -... From 03295cff933638d959a7070ae53e8a390c2281c6 Mon Sep 17 00:00:00 2001 From: Bodo Schulz Date: Tue, 12 Nov 2024 13:27:47 +0100 Subject: [PATCH 2/3] fix some lint for python --- .flake8 | 2 +- plugins/filter/grafana.py | 1 - plugins/filter/verify.py | 8 +++--- plugins/modules/grafana_api_keys.py | 2 +- plugins/modules/grafana_plugins.py | 26 +++++++++---------- plugins/modules/grafana_service_accounts.py | 2 +- plugins/modules/loki_verify_config.py | 6 ++--- plugins/modules/sync_dashboards.py | 2 +- .../molecule/configured/tests/test_default.py | 18 ++++++------- .../molecule/default/tests/test_grafana.py | 16 ++++++------ .../default/tests/test_grafana_service.py | 16 ++++++------ .../default/tests/test_grafana_user.py | 16 ++++++------ .../molecule/latest/tests/test_grafana.py | 16 ++++++------ .../latest/tests/test_grafana_service.py | 16 ++++++------ .../latest/tests/test_grafana_user.py | 16 ++++++------ .../molecule/upgrade/tests/test_default.py | 16 ++++++------ .../tests/test_default.py | 16 ++++++------ .../molecule/with-ldap/tests/test_default.py | 16 ++++++------ roles/loki/molecule/2.3/tests/test_default.py | 16 ++++++------ roles/loki/molecule/2.4/tests/test_default.py | 16 ++++++------ roles/loki/molecule/2.5/tests/test_default.py | 16 ++++++------ roles/loki/molecule/2.6/tests/test_default.py | 16 ++++++------ roles/loki/molecule/2.7/tests/test_default.py | 16 ++++++------ roles/loki/molecule/3.2/tests/test_default.py | 16 ++++++------ .../molecule/default/tests/test_default.py | 16 ++++++------ .../molecule/latest/tests/test_default.py | 16 ++++++------ .../molecule/with-redis/tests/test_default.py | 16 ++++++------ .../with-updates/tests/test_default.py | 16 ++++++------ .../custom-scrape-configs/tests/test_loki.py | 16 ++++++------ .../tests/test_promtail.py | 16 ++++++------ .../molecule/default/tests/test_loki.py | 16 ++++++------ .../molecule/default/tests/test_promtail.py | 16 ++++++------ .../molecule/latest/tests/test_loki.py | 16 ++++++------ .../molecule/latest/tests/test_promtail.py | 16 ++++++------ .../molecule/older/tests/test_loki.py | 16 ++++++------ .../molecule/older/tests/test_promtail.py | 16 ++++++------ .../molecule/with-updates/tests/test_loki.py | 16 ++++++------ .../with-updates/tests/test_promtail.py | 18 ++++++------- 38 files changed, 266 insertions(+), 267 deletions(-) diff --git a/.flake8 b/.flake8 index 1962f7e..c634542 100644 --- a/.flake8 +++ b/.flake8 @@ -3,7 +3,7 @@ # E221 multiple spaces before operator # E251 unexpected spaces around keyword / parameter equals -ignore = E221,E251 +# ignore = E221,E251 exclude = # No need to traverse our git directory diff --git a/plugins/filter/grafana.py b/plugins/filter/grafana.py index 7c37329..4b6ea95 100644 --- a/plugins/filter/grafana.py +++ b/plugins/filter/grafana.py @@ -99,7 +99,6 @@ def keyfiles(self, data): return result - def content_security_policy(self, data): """ """ diff --git a/plugins/filter/verify.py b/plugins/filter/verify.py index 9e63f95..d6ba090 100644 --- a/plugins/filter/verify.py +++ b/plugins/filter/verify.py @@ -106,8 +106,8 @@ def validate_datasource_type(self, data): ) return dict( - valid = True, - msg = "All datasources are valid." + valid=True, + msg="All datasources are valid." ) def absent_datasources(self, data): @@ -121,8 +121,8 @@ def absent_datasources(self, data): # res = {} if values.get("state", "present") == "absent": res = dict( - name = datasource, - orgId = values.get("org_id", 1) + name=datasource, + orgId=values.get("org_id", 1) ) result.append(res) diff --git a/plugins/modules/grafana_api_keys.py b/plugins/modules/grafana_api_keys.py index a6a3f33..09891eb 100644 --- a/plugins/modules/grafana_api_keys.py +++ b/plugins/modules/grafana_api_keys.py @@ -92,7 +92,7 @@ def run(self): self.module.log(msg=f" all : {self.grafana_api_keys} / {type(self.grafana_api_keys)}") present_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "present"] - absent_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "absent"] + absent_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "absent"] # disabled_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "disabled"] # self.module.log(msg=f" present : {present_keys}") diff --git a/plugins/modules/grafana_plugins.py b/plugins/modules/grafana_plugins.py index 4d74775..f95d9c5 100644 --- a/plugins/modules/grafana_plugins.py +++ b/plugins/modules/grafana_plugins.py @@ -98,9 +98,9 @@ def _list(self): _failed = False return dict( - failed = _failed, - changed = _changed, - installed = plugin_list + failed=_failed, + changed=_changed, + installed=plugin_list ) def _list_remote(self): @@ -162,9 +162,9 @@ def _install(self): if len(self.plugins) == 0: return dict( - failed = True, - changed =False, - msg = "Missing a list of Plugins to install." + failed=True, + changed=False, + msg="Missing a list of Plugins to install." ) plugin_list = self._list() @@ -196,8 +196,8 @@ def _install(self): res = {} res[p] = dict( - failed = False, - changed = False, + failed=False, + changed=False, state=f"already in version {plugin_version} installed." ) result_state.append(res) @@ -217,8 +217,8 @@ def _install(self): res = {} res[p] = dict( - failed = False, - changed = True, + failed=False, + changed=True, state=f"version {version_string} successfuly installed." ) result_state.append(res) @@ -249,9 +249,9 @@ def _install(self): # self.module.log(msg=f" result_msg : '{result_msg}'") return dict( - failed = failed, - changed = changed, - msg = result_msg + failed=failed, + changed=changed, + msg=result_msg ) def _uninstall(self): diff --git a/plugins/modules/grafana_service_accounts.py b/plugins/modules/grafana_service_accounts.py index 81b7078..bdc5906 100644 --- a/plugins/modules/grafana_service_accounts.py +++ b/plugins/modules/grafana_service_accounts.py @@ -94,7 +94,7 @@ def run(self): self.module.log(msg=f" account : {self.grafana_service_accounts}") present_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "present"] - absent_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "absent"] + absent_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "absent"] # disabled_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "disabled"] # self.module.log(msg=f" must present : {present_keys}") diff --git a/plugins/modules/loki_verify_config.py b/plugins/modules/loki_verify_config.py index 0179332..5d649ef 100644 --- a/plugins/modules/loki_verify_config.py +++ b/plugins/modules/loki_verify_config.py @@ -93,10 +93,10 @@ def run(self): msg = err result = dict( - failed = _failed, - changed = False, + failed=_failed, + changed=False, cmd=" ".join(args), - msg = msg + msg=msg ) return result diff --git a/plugins/modules/sync_dashboards.py b/plugins/modules/sync_dashboards.py index 47387b6..8462cbc 100644 --- a/plugins/modules/sync_dashboards.py +++ b/plugins/modules/sync_dashboards.py @@ -190,7 +190,7 @@ def main(): """ """ args = dict( - source_directory = dict( + source_directory=dict( required=True, type='str' ), diff --git a/roles/grafana/molecule/configured/tests/test_default.py b/roles/grafana/molecule/configured/tests/test_default.py index ad2eeb6..5289d51 100644 --- a/roles/grafana/molecule/configured/tests/test_default.py +++ b/roles/grafana/molecule/configured/tests/test_default.py @@ -45,7 +45,7 @@ def read_ansible_yaml(file_name, role_name): read_file = None for e in ["yml", "yaml"]: - test_file = "{}.{}".format(file_name, e) + test_file = f"{file_name}.{e}" if os.path.isfile(test_file): read_file = test_file break @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/default/tests/test_grafana.py b/roles/grafana/molecule/default/tests/test_grafana.py index 247c8aa..f1ffeca 100644 --- a/roles/grafana/molecule/default/tests/test_grafana.py +++ b/roles/grafana/molecule/default/tests/test_grafana.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/default/tests/test_grafana_service.py b/roles/grafana/molecule/default/tests/test_grafana_service.py index 78f3790..88fc536 100644 --- a/roles/grafana/molecule/default/tests/test_grafana_service.py +++ b/roles/grafana/molecule/default/tests/test_grafana_service.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/default/tests/test_grafana_user.py b/roles/grafana/molecule/default/tests/test_grafana_user.py index bf8b9e2..32d9757 100644 --- a/roles/grafana/molecule/default/tests/test_grafana_user.py +++ b/roles/grafana/molecule/default/tests/test_grafana_user.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/latest/tests/test_grafana.py b/roles/grafana/molecule/latest/tests/test_grafana.py index ce166ad..6c6ef4f 100644 --- a/roles/grafana/molecule/latest/tests/test_grafana.py +++ b/roles/grafana/molecule/latest/tests/test_grafana.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/latest/tests/test_grafana_service.py b/roles/grafana/molecule/latest/tests/test_grafana_service.py index 78f3790..88fc536 100644 --- a/roles/grafana/molecule/latest/tests/test_grafana_service.py +++ b/roles/grafana/molecule/latest/tests/test_grafana_service.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/latest/tests/test_grafana_user.py b/roles/grafana/molecule/latest/tests/test_grafana_user.py index bf8b9e2..32d9757 100644 --- a/roles/grafana/molecule/latest/tests/test_grafana_user.py +++ b/roles/grafana/molecule/latest/tests/test_grafana_user.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/upgrade/tests/test_default.py b/roles/grafana/molecule/upgrade/tests/test_default.py index 7420e03..abf9543 100644 --- a/roles/grafana/molecule/upgrade/tests/test_default.py +++ b/roles/grafana/molecule/upgrade/tests/test_default.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/with-database-cache-and-ldap/tests/test_default.py b/roles/grafana/molecule/with-database-cache-and-ldap/tests/test_default.py index 8f66542..dee234e 100644 --- a/roles/grafana/molecule/with-database-cache-and-ldap/tests/test_default.py +++ b/roles/grafana/molecule/with-database-cache-and-ldap/tests/test_default.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/grafana/molecule/with-ldap/tests/test_default.py b/roles/grafana/molecule/with-ldap/tests/test_default.py index f4f73ad..404c676 100644 --- a/roles/grafana/molecule/with-ldap/tests/test_default.py +++ b/roles/grafana/molecule/with-ldap/tests/test_default.py @@ -76,16 +76,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/2.3/tests/test_default.py b/roles/loki/molecule/2.3/tests/test_default.py index dfa7f1a..65c39fd 100644 --- a/roles/loki/molecule/2.3/tests/test_default.py +++ b/roles/loki/molecule/2.3/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/2.4/tests/test_default.py b/roles/loki/molecule/2.4/tests/test_default.py index 04c6483..7de1db2 100644 --- a/roles/loki/molecule/2.4/tests/test_default.py +++ b/roles/loki/molecule/2.4/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/2.5/tests/test_default.py b/roles/loki/molecule/2.5/tests/test_default.py index 04c6483..7de1db2 100644 --- a/roles/loki/molecule/2.5/tests/test_default.py +++ b/roles/loki/molecule/2.5/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/2.6/tests/test_default.py b/roles/loki/molecule/2.6/tests/test_default.py index 9bd751c..6b65566 100644 --- a/roles/loki/molecule/2.6/tests/test_default.py +++ b/roles/loki/molecule/2.6/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/2.7/tests/test_default.py b/roles/loki/molecule/2.7/tests/test_default.py index 9bd751c..6b65566 100644 --- a/roles/loki/molecule/2.7/tests/test_default.py +++ b/roles/loki/molecule/2.7/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/3.2/tests/test_default.py b/roles/loki/molecule/3.2/tests/test_default.py index 9bd751c..6b65566 100644 --- a/roles/loki/molecule/3.2/tests/test_default.py +++ b/roles/loki/molecule/3.2/tests/test_default.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/default/tests/test_default.py b/roles/loki/molecule/default/tests/test_default.py index ea9cd64..6cf4134 100644 --- a/roles/loki/molecule/default/tests/test_default.py +++ b/roles/loki/molecule/default/tests/test_default.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/latest/tests/test_default.py b/roles/loki/molecule/latest/tests/test_default.py index ea9cd64..6cf4134 100644 --- a/roles/loki/molecule/latest/tests/test_default.py +++ b/roles/loki/molecule/latest/tests/test_default.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/with-redis/tests/test_default.py b/roles/loki/molecule/with-redis/tests/test_default.py index 959d00e..79b08b3 100644 --- a/roles/loki/molecule/with-redis/tests/test_default.py +++ b/roles/loki/molecule/with-redis/tests/test_default.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/loki/molecule/with-updates/tests/test_default.py b/roles/loki/molecule/with-updates/tests/test_default.py index 571c585..a8d59a1 100644 --- a/roles/loki/molecule/with-updates/tests/test_default.py +++ b/roles/loki/molecule/with-updates/tests/test_default.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/custom-scrape-configs/tests/test_loki.py b/roles/promtail/molecule/custom-scrape-configs/tests/test_loki.py index b2037a7..809e0b2 100644 --- a/roles/promtail/molecule/custom-scrape-configs/tests/test_loki.py +++ b/roles/promtail/molecule/custom-scrape-configs/tests/test_loki.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/custom-scrape-configs/tests/test_promtail.py b/roles/promtail/molecule/custom-scrape-configs/tests/test_promtail.py index 31e417f..d21284c 100644 --- a/roles/promtail/molecule/custom-scrape-configs/tests/test_promtail.py +++ b/roles/promtail/molecule/custom-scrape-configs/tests/test_promtail.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/default/tests/test_loki.py b/roles/promtail/molecule/default/tests/test_loki.py index b2037a7..809e0b2 100644 --- a/roles/promtail/molecule/default/tests/test_loki.py +++ b/roles/promtail/molecule/default/tests/test_loki.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/default/tests/test_promtail.py b/roles/promtail/molecule/default/tests/test_promtail.py index 31e417f..d21284c 100644 --- a/roles/promtail/molecule/default/tests/test_promtail.py +++ b/roles/promtail/molecule/default/tests/test_promtail.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/latest/tests/test_loki.py b/roles/promtail/molecule/latest/tests/test_loki.py index b2037a7..809e0b2 100644 --- a/roles/promtail/molecule/latest/tests/test_loki.py +++ b/roles/promtail/molecule/latest/tests/test_loki.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/latest/tests/test_promtail.py b/roles/promtail/molecule/latest/tests/test_promtail.py index c10db4b..1996151 100644 --- a/roles/promtail/molecule/latest/tests/test_promtail.py +++ b/roles/promtail/molecule/latest/tests/test_promtail.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distribution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distribution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distribution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distribution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distribution_vars = host.ansible("include_vars", file_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distribution_vars = host.ansible("include_vars", file_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/older/tests/test_loki.py b/roles/promtail/molecule/older/tests/test_loki.py index b2037a7..809e0b2 100644 --- a/roles/promtail/molecule/older/tests/test_loki.py +++ b/roles/promtail/molecule/older/tests/test_loki.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/older/tests/test_promtail.py b/roles/promtail/molecule/older/tests/test_promtail.py index c10db4b..1996151 100644 --- a/roles/promtail/molecule/older/tests/test_promtail.py +++ b/roles/promtail/molecule/older/tests/test_promtail.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distribution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distribution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distribution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distribution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distribution_vars = host.ansible("include_vars", file_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distribution_vars = host.ansible("include_vars", file_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/with-updates/tests/test_loki.py b/roles/promtail/molecule/with-updates/tests/test_loki.py index b2037a7..809e0b2 100644 --- a/roles/promtail/molecule/with-updates/tests/test_loki.py +++ b/roles/promtail/molecule/with-updates/tests/test_loki.py @@ -74,16 +74,16 @@ def get_vars(host): # print(" -> {} / {}".format(distribution, os)) # print(" -> {}".format(base_dir)) - file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") - file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") - file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") - file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") + file_defaults = read_ansible_yaml("{}/defaults/main".format(base_dir), "role_defaults") + file_vars = read_ansible_yaml("{}/vars/main".format(base_dir), "role_vars") + file_distibution = read_ansible_yaml("{}/vars/{}".format(base_dir, os), "role_distibution") + file_molecule = read_ansible_yaml("{}/group_vars/all/vars".format(molecule_dir), "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars diff --git a/roles/promtail/molecule/with-updates/tests/test_promtail.py b/roles/promtail/molecule/with-updates/tests/test_promtail.py index 54d0038..d0bd311 100644 --- a/roles/promtail/molecule/with-updates/tests/test_promtail.py +++ b/roles/promtail/molecule/with-updates/tests/test_promtail.py @@ -73,16 +73,16 @@ def get_vars(host): elif distribution in ['arch', 'artix']: operation_system = f"{distribution}linux" - file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") - file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") - role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") - file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") + file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults") + file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars") + role_distribution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distribution") + file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars") # file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars") - defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") - vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") - distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") - molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") + defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults") + vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars") + distibution_vars = host.ansible("include_vars", role_distribution).get("ansible_facts").get("role_distribution") + molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars") # host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars") ansible_vars = defaults_vars @@ -178,7 +178,7 @@ def test_version(host, get_vars): f = host.file(version_file) assert f.is_file - link = host.file(current_link) + link = host.file(current_link) assert link.is_symlink assert link.linked_to == version_file From 58745024eb892bda1cb9fe4ff4d1db5b7277eca1 Mon Sep 17 00:00:00 2001 From: Bodo Schulz Date: Tue, 12 Nov 2024 15:50:01 +0100 Subject: [PATCH 3/3] fix module --- .github/workflows/loki.yml | 2 ++ plugins/modules/loki_verify_config.py | 28 ++++++++++++------- .../loki/molecule/2.6/group_vars/all/vars.yml | 14 ++++++++++ .../loki/molecule/2.7/group_vars/all/vars.yml | 16 ++++++++++- roles/loki/vars/main.yml | 10 +++---- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.github/workflows/loki.yml b/.github/workflows/loki.yml index 869fa11..62d0aa9 100644 --- a/.github/workflows/loki.yml +++ b/.github/workflows/loki.yml @@ -170,6 +170,8 @@ jobs: - with-updates - "2.5" - "2.6" + - "2.7" + - "3.2" collection_role: - loki diff --git a/plugins/modules/loki_verify_config.py b/plugins/modules/loki_verify_config.py index 5d649ef..316aeaa 100644 --- a/plugins/modules/loki_verify_config.py +++ b/plugins/modules/loki_verify_config.py @@ -77,20 +77,28 @@ def run(self): rc, out, err = self.__exec(args, check_rc=False) + err = err.strip() + # self.module.log(msg=f" -> '{err}' ({type(err)})") + if rc == 0: _failed = False - if isinstance(err, str): - err = json.loads(err) - - if isinstance(err, dict): - error_msg = err.get("err", None) - msg = err.get("msg", None) - - if rc != 0 and error_msg: - msg = error_msg.split("\n") + if rc != 0 and len(err) > 0: + if isinstance(err, str): + err = json.loads(err) + + if isinstance(err, dict): + # log_level = err.get("level", "info") + error_msg = err.get("err", None) + msg = err.get("msg", None) + # if log_level == "warn": + # msg = error_msg = err.get("msg", None) + if rc != 0 and error_msg: + msg = error_msg.split("\n") + else: + msg = err else: - msg = err + msg = "unknow config error." result = dict( failed=_failed, diff --git a/roles/loki/molecule/2.6/group_vars/all/vars.yml b/roles/loki/molecule/2.6/group_vars/all/vars.yml index cd5c50a..2d0b40b 100644 --- a/roles/loki/molecule/2.6/group_vars/all/vars.yml +++ b/roles/loki/molecule/2.6/group_vars/all/vars.yml @@ -6,4 +6,18 @@ loki_config_server: http_listen_address: "127.0.0.1" http_listen_port: 3100 +loki_config_schema: + configs: + - from: "2020-10-24" + store: boltdb # tsdb # + object_store: filesystem + schema: v11 # v13 # + index: + prefix: index_ + period: 168h # 24h # + chunks: + prefix: index_ + period: 168h + row_shards: 16 + ... diff --git a/roles/loki/molecule/2.7/group_vars/all/vars.yml b/roles/loki/molecule/2.7/group_vars/all/vars.yml index cd5c50a..c3fdf9f 100644 --- a/roles/loki/molecule/2.7/group_vars/all/vars.yml +++ b/roles/loki/molecule/2.7/group_vars/all/vars.yml @@ -1,9 +1,23 @@ --- -loki_version: "2.6.1" +loki_version: "2.7.4" loki_config_server: http_listen_address: "127.0.0.1" http_listen_port: 3100 +loki_config_schema: + configs: + - from: "2020-10-24" + store: boltdb # tsdb # + object_store: filesystem + schema: v11 # v13 # + index: + prefix: index_ + period: 168h # 24h # + chunks: + prefix: index_ + period: 168h + row_shards: 16 + ... diff --git a/roles/loki/vars/main.yml b/roles/loki/vars/main.yml index bfbc20d..13bc481 100644 --- a/roles/loki/vars/main.yml +++ b/roles/loki/vars/main.yml @@ -224,16 +224,16 @@ loki_defaults_config_chunk_store: {} loki_defaults_config_schema: configs: - - from: "2020-10-24" - store: boltdb # tsdb # + - from: "2024-01-01" + store: tsdb # tsdb # object_store: filesystem - schema: v11 # v13 # + schema: v13 # v13 # index: prefix: index_ - period: 168h # 24h # + period: 24h # 24h # chunks: prefix: index_ - period: 168h + period: 24h row_shards: 16 loki_defaults_config_limits: