log agent 수정
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
---
|
||||
- set_fact:
|
||||
datasaker_agents: "{{ datasaker_agents | reject('equalto', 'dsk-log-agent') | list }}"
|
||||
when: ansible_facts.distribution_version != "18.04"
|
||||
# - set_fact:
|
||||
# datasaker_agents: "{{ datasaker_agents | reject('equalto', 'dsk-log-agent') | list }}"
|
||||
# when: ansible_facts.distribution_version != "18.04"
|
||||
- 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'] == 'Amazon' and ansible_facts['distribution_major_version'] == '2' %}datasaker-amazonlinux-2
|
||||
{% elif ansible_facts['os_family'] == 'Debian'%}debian-repos
|
||||
{% else %}unknown{% endif %}"
|
||||
|
||||
- name: "Create temporary directory for key manipulation"
|
||||
tempfile:
|
||||
@@ -53,7 +60,7 @@
|
||||
update_cache: yes
|
||||
force: yes
|
||||
|
||||
- name: Make Datasaker Log Directory
|
||||
- name: "Make Datasaker Log Directory"
|
||||
ansible.builtin.file:
|
||||
path: "{{ datasaker_host_log_path }}/{{ item }}"
|
||||
state: directory
|
||||
@@ -77,13 +84,15 @@
|
||||
name: "td-agent"
|
||||
state: latest
|
||||
update_cache: yes
|
||||
when: '"dsk-log-agent" in datasaker_agents'
|
||||
when:
|
||||
- '"dsk-log-agent" in datasaker_agents'
|
||||
- log_agent_image_tag != "latest"
|
||||
|
||||
- name: Reload systemd configuration
|
||||
- name: "Reload systemd configuration"
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: True
|
||||
|
||||
- name: Restart dsk-agent service
|
||||
- name: "Restart dsk-agent service"
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
|
||||
@@ -19,13 +19,14 @@
|
||||
src: docker-log-agent-config.yml.j2
|
||||
dest: "{{ datasaker_docker_path }}/dsk-docker-log-agent-config.yml"
|
||||
|
||||
- name: Run Datasaker Log Agent
|
||||
- name: "Run Datasaker Log Agent"
|
||||
docker_container:
|
||||
name: dsk-docker-log-agent
|
||||
image: "datasaker/dsk-log-agent:{{ log_agent_image_tag }}"
|
||||
state: started
|
||||
detach: true
|
||||
restart_policy: "{{ log_agent_restart_policy }}"
|
||||
ports:
|
||||
- "{{ log_agent_port }}:{{ log_agent_port }}"
|
||||
env:
|
||||
DKS_LOG_LEVEL: "{{ log_agent_log_level }}"
|
||||
command: "-global.config=/etc/datasaker/global-config.yml -agent.config=/etc/datasaker/dsk-log-agent/agent-config.yml -mount.volume=true"
|
||||
@@ -33,5 +34,18 @@
|
||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||
- "{{ datasaker_docker_path }}/dsk-docker-log-agent-config.yml:/etc/datasaker/dsk-log-agent/agent-config.yml:ro"
|
||||
- "{{ item }}"
|
||||
loop: "{{ custom_log_volume | default(['{{ docker_default_path }}:/var/log/sample/:ro']) }}"
|
||||
- "{{ item }}:{{ item }}:ro"
|
||||
with_items: "{{ custom_log_volume | default(['{{ docker_default_path }}']) }}"
|
||||
|
||||
- name: "Run APP with fluentd logging"
|
||||
docker_container:
|
||||
name: "{{ app_name }}"
|
||||
image: "{{ app_image }}"
|
||||
state: started
|
||||
log_options:
|
||||
log-driver: fluentd
|
||||
log-opt:
|
||||
fluentd-address: "{{ log_agent_port }}:{{ log_agent_port }}"
|
||||
when:
|
||||
- app_name is defined
|
||||
- app_image is defined
|
||||
@@ -17,4 +17,49 @@
|
||||
- name: "Setting dsk-log-agent config"
|
||||
template:
|
||||
src: log-agent-config.yml.j2
|
||||
dest: "{{ datasaker_host_path }}/dsk-log-agent/agent-config.yml"
|
||||
dest: "{{ datasaker_host_path }}/dsk-log-agent/agent-config.yml"
|
||||
|
||||
- name: "Install fluent-bit"
|
||||
block:
|
||||
- name: "Install fluent-bit"
|
||||
shell: curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh
|
||||
rescue:
|
||||
- name: "Copy RPM files"
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "/tmp/"
|
||||
with_items:
|
||||
- "{{ role_path }}/files/libpq-13.5-1.el8.x86_64.rpm"
|
||||
- "{{ role_path }}/files/libpq-devel-13.5-1.el8.x86_64.rpm"
|
||||
when:
|
||||
- ansible_facts['os_family'] == 'RedHat'
|
||||
- ansible_facts['distribution_major_version'] == '8'
|
||||
- name: "Install libpq-13.5-1"
|
||||
command: rpm -ivh /tmp/{{ item }}
|
||||
with_items:
|
||||
- libpq-13.5-1.el8.x86_64.rpm
|
||||
- libpq-devel-13.5-1.el8.x86_64.rpm
|
||||
when:
|
||||
- ansible_facts['os_family'] == 'RedHat'
|
||||
- ansible_facts['distribution_major_version'] == '8'
|
||||
- template:
|
||||
src: fluent-bit-repo.yml.j2
|
||||
dest: "/etc/yum.repos.d/fluent-bit.repo"
|
||||
when:
|
||||
- ansible_facts['os_family'] == 'RedHat'
|
||||
- ansible_facts['distribution_major_version'] == '7'
|
||||
- yum:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- fluent-bit
|
||||
- file:
|
||||
path: /tmp/{{ item }}
|
||||
state: absent
|
||||
with_items:
|
||||
- libpq-13.5-1.el8.x86_64.rpm
|
||||
- libpq-devel-13.5-1.el8.x86_64.rpm
|
||||
when:
|
||||
- ansible_facts['os_family'] == 'RedHat'
|
||||
- ansible_facts['distribution_major_version'] == '8'
|
||||
@@ -1,14 +1,22 @@
|
||||
---
|
||||
- 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 }}"
|
||||
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 }}"
|
||||
# - set_fact:
|
||||
# datasaker_agents: "{{ datasaker_agents | reject('equalto', 'dsk-log-agent') | list }}"
|
||||
|
||||
- name: "Check datasaker Agent"
|
||||
include_tasks: check-agent.yml
|
||||
@@ -28,7 +36,9 @@
|
||||
name: "td-agent"
|
||||
state: latest
|
||||
update_cache: yes
|
||||
when: '"dsk-log-agent" in datasaker_agents'
|
||||
when:
|
||||
- '"dsk-log-agent" in datasaker_agents'
|
||||
- log_agent_image_tag != "latest"
|
||||
|
||||
- name: "Install datasaker agent"
|
||||
yum:
|
||||
@@ -40,4 +50,12 @@
|
||||
notify:
|
||||
- Reload systemd configuration
|
||||
- Restart {{ item }} service
|
||||
ignore_errors: true
|
||||
ignore_errors: true
|
||||
|
||||
- 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"
|
||||
Reference in New Issue
Block a user