aim-web2.1.0rc9
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
- name: Services | Validate selections
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- maintenance_service_include is sequence
|
||||
- maintenance_service_include is not string
|
||||
- maintenance_service_exclude is sequence
|
||||
- maintenance_service_exclude is not string
|
||||
- (maintenance_service_fail_on_error) is boolean or (maintenance_service_fail_on_error | string |
|
||||
lower) in ['true', 'false']
|
||||
fail_msg: Service selections must be lists of internal names; failure policy must be boolean.
|
||||
quiet: true
|
||||
- name: Services | Read current state
|
||||
ansible.windows.win_service_info: {}
|
||||
register: _aim_services
|
||||
- name: Services | Start eligible stopped services
|
||||
ansible.windows.win_service:
|
||||
name: '{{ item.name }}'
|
||||
state: started
|
||||
loop: '{{ _aim_services.services }}'
|
||||
loop_control:
|
||||
label: '{{ item.name }}'
|
||||
when:
|
||||
- item.state == 'stopped'
|
||||
- item.start_mode in ['auto', 'delayed']
|
||||
- maintenance_service_include | length == 0 or item.name in maintenance_service_include
|
||||
- item.name not in maintenance_service_exclude
|
||||
register: _aim_service_starts
|
||||
ignore_errors: true
|
||||
- name: Services | Observe states after start attempts
|
||||
ansible.windows.win_service_info: {}
|
||||
register: _aim_services_after
|
||||
- name: Services | Build before and after report
|
||||
ansible.builtin.set_fact:
|
||||
_aim_service_report: '{{ _aim_services.services | aim_report_services(_aim_service_starts.results | default([]),
|
||||
_aim_services_after.services, maintenance_service_include, maintenance_service_exclude, ansible_check_mode)
|
||||
}}'
|
||||
- name: Services | Summary
|
||||
ansible.builtin.debug:
|
||||
msg: '{{ _aim_service_report }}'
|
||||
- name: AIM | Publish operation result
|
||||
ansible.builtin.set_stats:
|
||||
per_host: true
|
||||
aggregate: false
|
||||
data:
|
||||
aim_output:
|
||||
protocol: aim_output_v1
|
||||
schema: service_start_summary_v1
|
||||
data: '{{ _aim_service_report }}'
|
||||
- name: Services | Report partial failure
|
||||
ansible.builtin.fail:
|
||||
msg: One or more attempted services are not running. See failed_to_start in the structured report.
|
||||
when:
|
||||
- maintenance_service_fail_on_error | bool
|
||||
- _aim_service_report.failed_count | int > 0
|
||||
- not ansible_check_mode
|
||||
Reference in New Issue
Block a user