2018-09-10 11:33:08 +02:00
|
|
|
---
|
|
|
|
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
|
|
|
#
|
|
|
|
# tasks file for fusioninventory
|
|
|
|
|
2020-09-30 16:05:10 +02:00
|
|
|
- name: Include package list per OS
|
2021-01-13 16:57:05 +01:00
|
|
|
include_vars: "{{ lookup('first_found', params) }}"
|
|
|
|
vars:
|
|
|
|
params:
|
|
|
|
files:
|
2021-06-10 16:29:21 +02:00
|
|
|
- '{{ ansible_distribution }}.yml'
|
|
|
|
- '{{ ansible_os_family }}.yml'
|
|
|
|
paths:
|
|
|
|
- 'vars'
|
|
|
|
|
2021-06-23 10:20:41 +02:00
|
|
|
# Manage fusioninventory related packages [[[1
|
|
|
|
- name: Ensure related packages are installed
|
2018-09-10 13:59:45 +02:00
|
|
|
package:
|
2021-06-23 10:20:41 +02:00
|
|
|
name: '{{ (fusioninventory__agent_depend_packages|d([]) +
|
|
|
|
fusioninventory__agent_recommend_packages|d([]) +
|
|
|
|
fusioninventory__agent_extra_packages|d([]))
|
|
|
|
| flatten }}'
|
2018-09-13 10:02:07 +02:00
|
|
|
state: 'present'
|
2019-02-27 14:07:23 +01:00
|
|
|
register: pkg_dep_result
|
|
|
|
until: pkg_dep_result is success
|
2021-08-02 12:06:25 +02:00
|
|
|
when: ((fusioninventory__agent_package_url|length > 0) and
|
|
|
|
(fusioninventory__agent_deploy_state == "present"))
|
2018-09-10 13:59:45 +02:00
|
|
|
|
2018-09-10 11:33:08 +02:00
|
|
|
# Manage agent package [[[1
|
2020-09-30 16:05:10 +02:00
|
|
|
|
|
|
|
# Specific tasks per OS will be in the include otherwise below
|
2021-06-10 16:29:21 +02:00
|
|
|
- name: Include tasks per OS
|
|
|
|
include: "{{ lookup('first_found', params) }}"
|
2021-01-13 16:57:05 +01:00
|
|
|
vars:
|
|
|
|
params:
|
|
|
|
files:
|
2021-06-10 16:29:21 +02:00
|
|
|
- '{{ ansible_distribution }}.yml'
|
|
|
|
- '{{ ansible_os_family }}.yml'
|
2018-09-10 11:33:08 +02:00
|
|
|
|
2018-09-10 14:55:42 +02:00
|
|
|
- name: Ensure fusioninventory-agent package from REPOS
|
2018-09-10 11:33:08 +02:00
|
|
|
package:
|
2021-06-22 15:56:25 +02:00
|
|
|
name: '{{ fusioninventory__agent_packages | flatten }}'
|
2018-09-13 10:21:44 +02:00
|
|
|
state: '{{ "present" if (fusioninventory__agent_deploy_state == "present")
|
|
|
|
else "absent" }}'
|
2019-02-27 14:07:23 +01:00
|
|
|
register: pkg_agent_repo_result
|
|
|
|
until: pkg_agent_repo_result is success
|
2021-08-02 12:06:25 +02:00
|
|
|
when: fusioninventory__agent_package_url|length == 0
|
2018-09-10 11:33:08 +02:00
|
|
|
|
2018-09-10 14:02:41 +02:00
|
|
|
# Manage agent configuration file [[[1
|
|
|
|
- name: Create Fusioninventory-agent configuration
|
|
|
|
template:
|
|
|
|
src: '{{ fusioninventory__agent_conf_src }}'
|
|
|
|
dest: "/etc/fusioninventory/agent.cfg"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0644'
|
|
|
|
when: fusioninventory__agent_deploy_state == "present"
|
2018-09-10 14:55:42 +02:00
|
|
|
notify: ['restart fusioninventory-agent service']
|
2023-08-07 10:48:51 +02:00
|
|
|
|
2023-08-04 09:59:00 +02:00
|
|
|
- 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"
|
2023-08-07 10:48:51 +02:00
|
|
|
|
|
|
|
- name: "Create cron entry when needed"
|
|
|
|
cron:
|
|
|
|
name: fusion-inventory-oneshot
|
|
|
|
cron_file: fusion-inventory-oneshot
|
|
|
|
day: "{{ fusioninventory__agent_conf_cron_day }}"
|
|
|
|
hour: "{{ fusioninventory__agent_conf_cron_hour }}"
|
|
|
|
minute: "{{ fusioninventory__agent_conf_cron_minute }}"
|
|
|
|
month: "{{ fusioninventory__agent_conf_cron_month }}"
|
|
|
|
weekday: "{{ fusioninventory__agent_conf_cron_weekday }}"
|
|
|
|
user: "{{ fusioninventory__agent_conf_cron_user }}"
|
|
|
|
state: "{{ fusioninventory__agent_conf_cron }}"
|
|
|
|
job: "{{ fusioninventory__agent_conf_command }}"
|
2023-08-07 15:00:40 +02:00
|
|
|
|