From 492031108ece622eb21621e8e26f1bfb458812a6 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Tue, 9 Jun 2020 13:37:41 +0100 Subject: [PATCH] Remove fail: tasks Assume that the operator knows what they are doing. These tasks are skipped for every service which bumps up the number of tasks and runtime. Change-Id: I73f38d6b9cc897537053d810d5cdd61ed74671fb --- tasks/main.yml | 56 ------------------------------------------ tests/test.yml | 66 -------------------------------------------------- 2 files changed, 122 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 53559ba..34fdcfd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -142,62 +142,6 @@ tags: - systemd-service -- name: Check ExecStarts - fail: - msg: >- - When the service type is "simple" only ONE command can be started. Check - The list of execstarts and limit it to a single command per service or - consider using the "oneshot" service type. Defined ExecStart commands - "{{ item.execstarts }}". - when: - - item.execstarts is not string - - item.execstarts | length > 1 - - item.service_type | default(systemd_default_service_type) != 'oneshot' - with_items: "{{ systemd_services }}" - tags: - - systemd-service - -- name: Check ExecStops - fail: - msg: >- - When the service type is "simple" only ONE command can be stopped. Check - The list of execstops and limit it to a single command per service or - consider using the "oneshot" service type. Defined ExecStop commands - "{{ item.execstops }}". - when: - - item.execstops is not string - - item.execstops | default([]) | length > 1 - - item.service_type | default(systemd_default_service_type) != 'oneshot' - with_items: "{{ systemd_services }}" - tags: - - systemd-service - -- name: Check ExecReloads - fail: - msg: >- - When the service type is "simple" only ONE command can be reloaded. Check - The list of execreloads and limit it to a single command per service or - consider using the "oneshot" service type. Defined ExecStop commands - "{{ item.execreloads }}". - when: - - item.execreloads is not string - - item.execreloads | default([]) | length > 1 - - item.service_type | default(systemd_default_service_type) != 'oneshot' - with_items: "{{ systemd_services }}" - tags: - - systemd-service - -- name: Check timers - fail: - msg: >- - When using systemd timers the "state" must be defined under the timer key. - when: - - item.timer is defined - - item.timer.state is undefined - with_items: "{{ systemd_services }}" - tags: - - systemd-service - - name: Place the systemd service config_template: src: "systemd-service.j2" diff --git a/tests/test.yml b/tests/test.yml index 6287346..661b50f 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -173,72 +173,6 @@ tags: - skip_ansible_lint - - name: Test failure condition - block: - - name: Run the systemd service role - include_role: - name: systemd_service - vars: - systemd_services: - - service_name: "test simple service1" - execstarts: - - "/bin/bash -c 'while true; do sleep 2 && echo test simple service1; done'" - - "/bin/bash -c 'while true; do sleep 2 && echo test simple service2; done'" - rescue: - - name: Set negative service test pass fact - set_fact: - systemd_service_execstarts_test: true - - - name: Test failure condition - block: - - name: Run the systemd service role - include_role: - name: systemd_service - vars: - systemd_services: - - service_name: "test simple service2" - execstarts: "/bin/bash -c 'while true; do sleep 2 && echo test simple service; done'" - execstops: - - /bin/true - - /bin/true - rescue: - - name: Set negative service test pass fact - set_fact: - systemd_service_execstops_test: true - - - name: Test failure condition - block: - - name: Run the systemd service role - include_role: - name: systemd_service - vars: - systemd_services: - - service_name: "test simple service3" - execstarts: "/bin/true" - execreloads: - - /bin/true - - /bin/true - rescue: - - name: Set negative service test pass fact - set_fact: - systemd_service_execreloads_test: true - - - name: Check negative service testing - fail: - msg: >- - Failed negative service testing. Results -- - systemd_service_execstarts_test: {{ systemd_service_execstarts_test }}, - systemd_service_execstops_test: {{ systemd_service_execstops_test }}, - systemd_service_execreloads_test: {{ systemd_service_execreloads_test }} - when: - - (not systemd_service_execstarts_test | bool) or - (not systemd_service_execstops_test | bool) or - (not systemd_service_execreloads_test | bool) - - name: Notify tests passed debug: msg: All tests have passed - vars: - systemd_service_execstarts_test: false - systemd_service_execstops_test: false - systemd_service_execreloads_test: false