2
0
Fork 0

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:
Tristan Charbonneau 2023-08-04 09:59:00 +02:00
parent 575004b092
commit 417f6fc58f
2 changed files with 20 additions and 0 deletions

View File

@ -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 [[[

View File

@ -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"