Skip to content

Commit

Permalink
Rename directory to scrape_configs
Browse files Browse the repository at this point in the history
Signed-off-by: Leonhard Mayr <[email protected]>
  • Loading branch information
manzsolutions-lpr committed Oct 4, 2024
1 parent 47014f0 commit 053626f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 42 deletions.
4 changes: 2 additions & 2 deletions roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ prometheus_static_targets_files:
- prometheus/targets/*.json

prometheus_scrape_config_files:
- prometheus/scrapes/*.yml
- prometheus/scrapes/*.json
- prometheus/scrape_configs/*.yml
- prometheus/scrape_configs/*.json

# yamllint disable rule:line-length
prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
Expand Down
2 changes: 1 addition & 1 deletion roles/prometheus/molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ provisioner:
labels:
env: demo
prometheus_scrape_config_files:
- /tmp/prometheus/scrapes/*.yml
- /tmp/prometheus/scrape_configs/*.yml
prometheus_scrape_configs:
- job_name: "prometheus"
metrics_path: "{{ prometheus_metrics_path }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/prometheus/molecule/alternative/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
tasks:
- name: Create scrapes directory
ansible.builtin.file:
name: /tmp/prometheus/scrapes
name: /tmp/prometheus/scrape_configs
state: directory
recurse: true
check_mode: false
- name: Create empty scrape config file
ansible.builtin.file:
name: /tmp/prometheus/scrapes/empty_scrapes.yml
name: /tmp/prometheus/scrape_configs/empty_scrapes.yml
state: touch
mode: 0664
check_mode: false
Expand Down
38 changes: 22 additions & 16 deletions roles/prometheus/molecule/alternative/tests/test_alternative.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,34 @@
testinfra_hosts = get_target_hosts()


@pytest.mark.parametrize("dirs", [
"/opt/prom/etc",
"/opt/prom/etc/rules",
"/opt/prom/etc/file_sd",
"/opt/prom/etc/scrapes",
"/opt/prom/lib"
])
@pytest.mark.parametrize(
"dirs",
[
"/opt/prom/etc",
"/opt/prom/etc/rules",
"/opt/prom/etc/file_sd",
"/opt/prom/etc/scrape_configs",
"/opt/prom/lib",
],
)
def test_directories(host, dirs):
d = host.file(dirs)
assert d.is_directory
assert d.exists


@pytest.mark.parametrize("files", [
"/opt/prom/etc/prometheus.yml",
"/opt/prom/etc/rules/ansible_managed.rules",
"/opt/prom/etc/file_sd/node.yml",
"/opt/prom/etc/file_sd/docker.yml",
"/opt/prom/etc/scrapes/empty_scrapes.yml",
"/usr/local/bin/prometheus",
"/usr/local/bin/promtool"
])
@pytest.mark.parametrize(
"files",
[
"/opt/prom/etc/prometheus.yml",
"/opt/prom/etc/rules/ansible_managed.rules",
"/opt/prom/etc/file_sd/node.yml",
"/opt/prom/etc/file_sd/docker.yml",
"/opt/prom/etc/scrape_configs/empty_scrapes.yml",
"/usr/local/bin/prometheus",
"/usr/local/bin/promtool",
],
)
def test_files(host, files):
f = host.file(files)
assert f.exists
Expand Down
4 changes: 2 additions & 2 deletions roles/prometheus/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
tasks:
- name: Create scrapes directory
ansible.builtin.file:
name: "{{ playbook_dir }}/../../prometheus/scrapes"
name: "{{ playbook_dir }}/../../prometheus/scrape_configs"
state: directory
recurse: true
check_mode: false
- name: Create empty scrape config file
ansible.builtin.file:
name: "{{ playbook_dir }}/../../prometheus/scrapes/empty_scrapes.yml"
name: "{{ playbook_dir }}/../../prometheus/scrape_configs/empty_scrapes.yml"
state: touch
mode: 0664
check_mode: false
44 changes: 25 additions & 19 deletions roles/prometheus/molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,37 @@ def AnsibleDefaults():
return yaml.full_load(stream)


@pytest.mark.parametrize("dirs", [
"/etc/prometheus",
"/etc/prometheus/console_libraries",
"/etc/prometheus/consoles",
"/etc/prometheus/rules",
"/etc/prometheus/file_sd",
"/etc/prometheus/scrapes",
"/var/lib/prometheus"
])
@pytest.mark.parametrize(
"dirs",
[
"/etc/prometheus",
"/etc/prometheus/console_libraries",
"/etc/prometheus/consoles",
"/etc/prometheus/rules",
"/etc/prometheus/file_sd",
"/etc/prometheus/scrape_configs",
"/var/lib/prometheus",
],
)
def test_directories(host, dirs):
d = host.file(dirs)
assert d.is_directory
assert d.exists


@pytest.mark.parametrize("files", [
"/etc/prometheus/prometheus.yml",
"/etc/prometheus/console_libraries/prom.lib",
"/etc/prometheus/consoles/prometheus.html",
"/etc/prometheus/scrapes/empty_scrapes.yml",
"/etc/prometheus/web.yml",
"/etc/systemd/system/prometheus.service",
"/usr/local/bin/prometheus",
"/usr/local/bin/promtool"
])
@pytest.mark.parametrize(
"files",
[
"/etc/prometheus/prometheus.yml",
"/etc/prometheus/console_libraries/prom.lib",
"/etc/prometheus/consoles/prometheus.html",
"/etc/prometheus/scrape_configs/empty_scrapes.yml",
"/etc/prometheus/web.yml",
"/etc/systemd/system/prometheus.service",
"/usr/local/bin/prometheus",
"/usr/local/bin/promtool",
],
)
def test_files(host, files):
f = host.file(files)
assert f.exists
Expand Down

0 comments on commit 053626f

Please sign in to comment.