ansible-development-environ.../roles/service/tasks/assert.yml

93 lines
2.3 KiB
YAML

---
- name: test if service_list is set correctly
ansible.builtin.assert:
that:
- service_list is defined
- service_list is iterable
quiet: yes
- name: test if item in service_list is set correctly
ansible.builtin.assert:
that:
- item.name is defined
- item.name is string
- item.description is defined
- item.description is string
- item.start_command is defined
- item.start_command is string
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
- name: test if type in service_list is set correctly
ansible.builtin.assert:
that:
- item.type is string
- item.type in [ "forking", "oneshot", "simple" ]
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.type is defined
- name: test if environment_variables in service_list is set correctly
ansible.builtin.assert:
that:
- item.environment_variables is iterable
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.environment_variables is defined
- name: test if restart_mode in service_list is set correctly
ansible.builtin.assert:
that:
- item.restart_mode is string
- item.restart_mode in [ "no", "on-success", "on-failure", "on-abnormal", "on-watchdog", "on-abort", "always" ]
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.restart_mode is defined
- name: test if restart_seconds in service_list is set correctly
ansible.builtin.assert:
that:
- item.seconds is number
- item.seconds >= 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.seconds is defined
- name: test if state in service_list is set correctly
ansible.builtin.assert:
that:
- item.state is string
- item.state in [ "reloaded", "restarted", "started", "stopped" ]
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.state is defined
- name: test if enabled in service_list is set correctly
ansible.builtin.assert:
that:
- item.enabled is boolean
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- item.enabled is defined