70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
---
|
|
- name: Set os-specific variables
|
|
set_fact:
|
|
os_specific: "{% if ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7' %}datasaker-redhat-7
|
|
{% elif ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8' %}datasaker-redhat-8
|
|
{% elif ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '9' %}datasaker-redhat-9
|
|
{% elif ansible_facts['os_family'] == 'Amazon' and ansible_facts['distribution_major_version'] == '2' %}datasaker-amazonlinux-2
|
|
{% else %}unknown{% endif %}"
|
|
|
|
- name: "Add datasaker repository"
|
|
yum_repository:
|
|
name: datasaker
|
|
description: datasaker-repo
|
|
baseurl: "{{ datasaker_yum_repo }}{{ os_specific }}"
|
|
enabled: "{{ datasaker_yum_enabled }}"
|
|
gpgcheck: "{{ datasaker_yum_gpgcheck }}"
|
|
|
|
# - set_fact:
|
|
# datasaker_agents: "{{ datasaker_agents | reject('equalto', 'dsk-log-agent') | list }}"
|
|
|
|
- name: Make Datasaker Log Directory
|
|
ansible.builtin.file:
|
|
path: "{{ datasaker_host_log_path }}/{{ item }}"
|
|
state: directory
|
|
recurse: yes
|
|
owner: root
|
|
group: root
|
|
with_items:
|
|
- "{{ datasaker_agents }}"
|
|
|
|
- name: "Install datasaker log agent"
|
|
apt:
|
|
name: "td-agent"
|
|
state: latest
|
|
update_cache: yes
|
|
when:
|
|
- '"dsk-log-agent" in datasaker_agents'
|
|
- log_agent_image_tag != "latest"
|
|
|
|
- name: "Install datasaker agent"
|
|
yum:
|
|
name: "{{ item }}"
|
|
state: present
|
|
update_cache: yes
|
|
with_items:
|
|
- "{{ datasaker_agents }}"
|
|
notify:
|
|
- Reload systemd configuration
|
|
- Restart {{ item }} service
|
|
ignore_errors: true
|
|
|
|
- name: "Check datasaker Agent"
|
|
include_tasks: check-agent.yml
|
|
|
|
- name: "Setting dsk-log-agent config"
|
|
template:
|
|
src: log-agent-config.yml.j2
|
|
dest: "{{ datasaker_host_path }}/dsk-log-agent/agent-config.yml"
|
|
when:
|
|
- '"dsk-log-agent" in datasaker_agents'
|
|
- log_agent_image_tag == "latest"
|
|
|
|
- name: "Restart dsk-agent service"
|
|
systemd_service:
|
|
state: restarted
|
|
name: "{{ item }}"
|
|
enabled: true
|
|
with_items:
|
|
- "{{ datasaker_agents }}"
|
|
ignore_errors: true |