diff --git a/CHANGELOG.md b/CHANGELOG.md index fc5e0f0..73e74e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ * Install dependent packages for fusioninventory-agent. * Install fusioninventory-agent package from URL. * Generate agent's configuration file. +* Restart agent's service if needed. diff --git a/README.md b/README.md index 3b8a64f..2761ca2 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ This role will : * Install needed dependent packages of fusioninventory-agent. * Install fusioninventory-agent package from official project package/URL. * Generate agent's configuration file. +* Manage agent's systemd service. ## Development diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..fa5f528 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,7 @@ +--- +# handlers file for fusioninventory-agent +- name: restart fusioninventory-agent service + service: + name: '{{ fusioninventory__agent_service_name }}' + state: "restarted" + enabled: '{{ fusioninventory__agent_service_manage | bool }}' diff --git a/tasks/main.yml b/tasks/main.yml index ab729b7..e688ab3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,13 +12,13 @@ - '{{ fusioninventory__agent_depend_packages }}' # Manage agent package [[[1 -- name: Ensure fusioninventory agent package from URL +- name: Ensure fusioninventory-agent package from URL apt: deb: '{{ fusioninventory__agent_package_url | d(omit) }}' state: '{{ "present" if (fusioninventory__agent_deploy_state == "present") else "absent" }}' when: fusioninventory__agent_package_url != "" -- name: Ensure fusioninventory agent package from REPOS +- name: Ensure fusioninventory-agent package from REPOS package: name: 'fusioninventory-agent' state: '{{ "present" if (fusioninventory__agent_deploy_state == "present") else "absent" }}' @@ -33,3 +33,4 @@ group: root mode: '0644' when: fusioninventory__agent_deploy_state == "present" + notify: ['restart fusioninventory-agent service']