2
0
Fork 0
This repository has been archived on 2023-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
ansible.fusioninventory/tasks/main.yml

80 lines
2.7 KiB
YAML

---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for fusioninventory
- name: Include package list per OS
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
paths:
- 'vars'
# Manage fusioninventory related packages [[[1
- name: Ensure related packages are installed
package:
name: '{{ (fusioninventory__agent_depend_packages|d([]) +
fusioninventory__agent_recommend_packages|d([]) +
fusioninventory__agent_extra_packages|d([]))
| flatten }}'
state: 'present'
register: pkg_dep_result
until: pkg_dep_result is success
when: ((fusioninventory__agent_package_url|length > 0) and
(fusioninventory__agent_deploy_state == "present"))
# Manage agent package [[[1
# Specific tasks per OS will be in the include otherwise below
- name: Include tasks per OS
include: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
- name: Ensure fusioninventory-agent package from REPOS
package:
name: '{{ fusioninventory__agent_packages | flatten }}'
state: '{{ "present" if (fusioninventory__agent_deploy_state == "present")
else "absent" }}'
register: pkg_agent_repo_result
until: pkg_agent_repo_result is success
when: fusioninventory__agent_package_url|length == 0
# 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"
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"
- 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 }}"