feat(service): manage service status and state
Service can either be enabled or disabled, enabled by default Service can either be started, stopped, restarted, reloaded, started by default
This commit is contained in:
parent
575004b092
commit
417f6fc58f
|
@ -44,6 +44,19 @@ fusioninventory__agent_deploy_state: 'present'
|
||||||
# The service name to manage.
|
# The service name to manage.
|
||||||
#
|
#
|
||||||
fusioninventory__agent_service_name: 'fusioninventory-agent'
|
fusioninventory__agent_service_name: 'fusioninventory-agent'
|
||||||
|
# ]]]
|
||||||
|
# .. envvar:: fusioninventory__agent_service_status [[[
|
||||||
|
#
|
||||||
|
# The targeted service status.
|
||||||
|
#
|
||||||
|
fusioninventory__agent_service_status: 'started'
|
||||||
|
# ]]]
|
||||||
|
|
||||||
|
# .. envvar:: fusioninventory__agent_service_enabled [[[
|
||||||
|
#
|
||||||
|
# The targeted service status.
|
||||||
|
#
|
||||||
|
fusioninventory__agent_service_enabled: true
|
||||||
|
|
||||||
# ]]]
|
# ]]]
|
||||||
# .. envvar:: fusioninventory__agent_service_manage [[[
|
# .. envvar:: fusioninventory__agent_service_manage [[[
|
||||||
|
|
|
@ -56,3 +56,10 @@
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
when: fusioninventory__agent_deploy_state == "present"
|
when: fusioninventory__agent_deploy_state == "present"
|
||||||
notify: ['restart fusioninventory-agent service']
|
notify: ['restart fusioninventory-agent service']
|
||||||
|
|
||||||
|
- name: Ensure the service is in the correct state
|
||||||
|
service:
|
||||||
|
name: "{{ fusioninventory__agent_service_name }}"
|
||||||
|
state: "{{ fusioninventory__agent_service_status }}"
|
||||||
|
enabled: "{{ fusioninventory__agent_service_enabled }}"
|
||||||
|
when: fusioninventory__agent_deploy_state == "present"
|
||||||
|
|
Reference in New Issue