diff options
Diffstat (limited to 'molecule/default')
| -rw-r--r-- | molecule/default/converge.yml | 16 | ||||
| -rw-r--r-- | molecule/default/tests/test_lineinfile_strategy.py | 4 | ||||
| -rw-r--r-- | molecule/default/tests/test_yaml_strategy.py | 33 |
3 files changed, 32 insertions, 21 deletions
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 8e0b5c9..166e8dc 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -62,7 +62,7 @@ - name: Lineinfile subsequent hosts and parallel writes hosts: application_group pre_tasks: - - name: Create lineinfile parallel target + - name: Create lineinfile parallel target # noqa: run-once[task] ansible.builtin.copy: dest: /opt/lineinfile_parallel.yml owner: prometheus @@ -435,11 +435,9 @@ - { host: exporter_without_id, path: simple_target4.yml } - { id: blackbox_exporter, path: simple_target3.yml } - { id: prefixed_exporter } - - { - id: prefixed_exporter, - path: /opt/prefix_target2.yml, - path_prefix: "", - } + - id: prefixed_exporter + path: /opt/prefix_target2.yml + path_prefix: "" - { id: prefixed_other, path: prefix_target3.yml } ################################################################################ @@ -682,7 +680,7 @@ - name: Handler execution matrix hosts: application_group pre_tasks: - - name: Create handler matrix target + - name: Create handler matrix target # noqa: run-once[task] ansible.builtin.copy: dest: /opt/handler_matrix.yml content: "" @@ -698,8 +696,8 @@ prometheus_target_handler_command_become: false prometheus_target_handler_command_run_once: false prometheus_target_handler_command: - cmd: "touch /tmp/command-handler-{{ inventory_hostname }}" - creates: "/tmp/command-handler-{{ inventory_hostname }}" + cmd: touch /tmp/command-handler-{{ inventory_hostname }} + creates: /tmp/command-handler-{{ inventory_hostname }} prometheus_target_handler_shell_enabled: true prometheus_target_handler_shell_become: false prometheus_target_handler_shell_run_once: true diff --git a/molecule/default/tests/test_lineinfile_strategy.py b/molecule/default/tests/test_lineinfile_strategy.py index d7f9738..77363ac 100644 --- a/molecule/default/tests/test_lineinfile_strategy.py +++ b/molecule/default/tests/test_lineinfile_strategy.py @@ -20,7 +20,9 @@ def test_lineinfile_bootstrap_adds_first_host_without_breaking_yaml(host): assert target.user == "prometheus" assert target.group == "prometheus" assert target.mode == 0o600 - assert read_yaml_file(host, "/opt/lineinfile_first_host.yml") == ["application:9100"] + assert read_yaml_file(host, "/opt/lineinfile_first_host.yml") == [ + "application:9100" + ] def test_lineinfile_adds_subsequent_host_to_existing_yaml(host): diff --git a/molecule/default/tests/test_yaml_strategy.py b/molecule/default/tests/test_yaml_strategy.py index 7f9b6ed..9e14b80 100644 --- a/molecule/default/tests/test_yaml_strategy.py +++ b/molecule/default/tests/test_yaml_strategy.py @@ -72,14 +72,19 @@ def test_yaml_user_edited_file_is_reparsed_and_keeps_expected_semantics(host): "targets" ] == ["application2:9200"] - assert get_unlabeled_group(groups)["targets"] == ["unlabeled:9100", "standalone:9300"] + assert get_unlabeled_group(groups)["targets"] == [ + "unlabeled:9100", + "standalone:9300", + ] def test_yaml_moving_host_removes_last_host_from_old_group(host): groups = read_yaml_file(host, "/opt/yaml_move_remove_last.yml") assert not has_group_with_labels(groups, {"job": "old"}) - assert get_group_by_labels(groups, {"job": "new"})["targets"] == ["application:9400"] + assert get_group_by_labels(groups, {"job": "new"})["targets"] == [ + "application:9400" + ] def test_yaml_output_remains_parseable_after_all_operations(host): @@ -110,12 +115,14 @@ def test_yaml_branch_matrix_covers_exact_match_and_append(host): "application3:9506", ] - assert get_group_by_labels(groups, {"job": "present", "env": "prod"})["targets"] == [ - "application3:9501" - ] + assert get_group_by_labels(groups, {"job": "present", "env": "prod"})[ + "targets" + ] == ["application3:9501"] -def test_yaml_branch_matrix_keeps_nonmatching_groups_for_both_label_mismatch_paths(host): +def test_yaml_branch_matrix_keeps_nonmatching_groups_for_both_label_mismatch_paths( + host, +): groups = read_yaml_file(host, "/opt/yaml_branch_matrix.yml") assert get_group_by_labels(groups, {"job": "wrong", "env": "prod"})["targets"] == [ @@ -126,7 +133,9 @@ def test_yaml_branch_matrix_keeps_nonmatching_groups_for_both_label_mismatch_pat "keep_length_mismatch:9500" ] - assert get_group_by_labels(groups, {"job": "foreign"})["targets"] == ["foreign:9505"] + assert get_group_by_labels(groups, {"job": "foreign"})["targets"] == [ + "foreign:9505" + ] def test_yaml_branch_matrix_moves_hosts_and_drops_emptied_groups(host): @@ -152,7 +161,9 @@ def test_yaml_branch_matrix_preserves_unlabeled_group_when_targets_remain(host): ] -def test_yaml_branch_matrix_creates_missing_file_groups_for_labeled_and_unlabeled_targets(host): +def test_yaml_branch_matrix_creates_missing_file_groups_for_labeled_and_unlabeled_targets( + host, +): assert read_yaml_file(host, "/opt/yaml_missing_labeled.yml") == [ {"labels": {"team": "infra"}, "targets": ["application4:9600"]} ] @@ -165,9 +176,9 @@ def test_yaml_branch_matrix_creates_missing_file_groups_for_labeled_and_unlabele def test_yaml_exporter_defaults_merge_labels_and_deduplicate(host): groups = read_yaml_file(host, "/opt/yaml_defaults.yml") - assert get_group_by_labels( - groups, {"job": "inherited", "environment": "staging"} - )["targets"] == ["application:9700"] + assert get_group_by_labels(groups, {"job": "inherited", "environment": "staging"})[ + "targets" + ] == ["application:9700"] assert get_group_by_labels(groups, {"job": "default"})["targets"] == [ "appended-default:9701" ] |