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

115 lines
2.8 KiB
YAML

---
- name: test if service_list is set correctly
assert:
that:
- service_list | length > 0
- service_list is iterable
quiet: yes
when:
- service_list is defined
- name: test if item in service_list is set correctly
assert:
that:
- item.name is defined
- item.name | length > 0
- item.description is defined
- item.description | length > 0
- item.start_command is defined
- item.start_command | length > 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- name: test if stop_command in service_list is set correctly
assert:
that:
- item.stop_command | length > 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.stop_command is defined
- name: test if type in service_list is set correctly
assert:
that:
- item.type | length > 0
- item.type in ["forking", "oneshot", "simple"]
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.type is defined
- name: test if working_directory in service_list is set correctly
assert:
that:
- item.working_directory | length > 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.working_directory is defined
- name: test if environment_variables in service_list is set correctly
assert:
that:
- item.environment_variables | length > 0
- item.environment_variables is iterable
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.environment_variables is defined
- name: test if after in service_list is set correctly
assert:
that:
- item.after | length > 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.after is defined
- name: test if restart_mode in service_list is set correctly
assert:
that:
- item.restart_mode | length > 0
- 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:
- service_list is defined
- item.restart_mode is defined
- name: test if restart_seconds in service_list is set correctly
assert:
that:
- item.seconds | length > 0
- item.seconds | int
- item.seconds | int >= 0
quiet: yes
loop: "{{ service_list }}"
loop_control:
label: "{{ item.name }}"
when:
- service_list is defined
- item.seconds is defined