update
This commit is contained in:
@@ -8,7 +8,7 @@ The Ansible Datasaker role installs and configures the Datasaker Agent and integ
|
|||||||
|
|
||||||
- Requires Ansible v2.6+.
|
- Requires Ansible v2.6+.
|
||||||
- Supports most Debian Linux distributions.
|
- Supports most Debian Linux distributions.
|
||||||
- Supports Amazon Linux 2023 distributions.
|
- Supports Amazon Linux 2 distributions.
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ apt_usr_share_keyring: "/usr/share/keyrings/datasaker-archive-keyring.gpg"
|
|||||||
dsk_public_gpg_key: "https://dsk-agent-s3.s3.ap-northeast-2.amazonaws.com/dsk-agent-s3/public/public.gpg.key"
|
dsk_public_gpg_key: "https://dsk-agent-s3.s3.ap-northeast-2.amazonaws.com/dsk-agent-s3/public/public.gpg.key"
|
||||||
|
|
||||||
datasaker_agents: ['dsk-node-agent']
|
datasaker_agents: ['dsk-node-agent']
|
||||||
|
datasaker_docker_agents: []
|
||||||
datasaker_docker_agents: ['dsk-docker-node-agent']
|
|
||||||
|
|
||||||
datasaker_docker_config_path: "~/.datasaker"
|
datasaker_docker_config_path: "~/.datasaker"
|
||||||
datasaker_docker_global_config: "{{ datasaker_docker_config_path }}/config.yml"
|
datasaker_docker_global_config: "{{ datasaker_docker_config_path }}/config.yml"
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
- name: "Check dsk-log-agent"
|
- name: "Check dsk-log-agent"
|
||||||
include_tasks: dsk-log-agent.yml
|
include_tasks: dsk-log-agent.yml
|
||||||
when: '"dsk-log-agent" in datasaker_agents'
|
when:
|
||||||
|
- '"dsk-log-agent" in datasaker_agents'
|
||||||
|
|
||||||
- name: "Check dsk-postgres-agent"
|
- name: "Check dsk-postgres-agent"
|
||||||
include_tasks: dsk-postgres-agent.yml
|
include_tasks: dsk-postgres-agent.yml
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
when:
|
when:
|
||||||
- datasaker_docker_agents
|
- datasaker_docker_agents
|
||||||
|
|
||||||
- name: "Touch agent config"
|
- name: "Create agent config"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ datasaker_docker_global_config }}"
|
path: "{{ datasaker_docker_global_config }}"
|
||||||
state: touch
|
state: touch
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
src: global-config.yml.j2
|
src: global-config.yml.j2
|
||||||
dest: "/etc/datasaker/global-config.yml"
|
dest: "/etc/datasaker/global-config.yml"
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
datasaker_agents: "{{ datasaker_agents | reject('equalto', 'dsk-log-agent') | list }}"
|
||||||
|
when: ansible_facts.distribution_version != "18.04"
|
||||||
|
|
||||||
- name: "Create temporary directory for key manipulation"
|
- name: "Create temporary directory for key manipulation"
|
||||||
tempfile:
|
tempfile:
|
||||||
state: directory
|
state: directory
|
||||||
@@ -67,10 +71,29 @@
|
|||||||
- name: "Install datasaker agent"
|
- name: "Install datasaker agent"
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: latest
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ datasaker_agents }}"
|
- "{{ datasaker_agents }}"
|
||||||
notify:
|
# - Restart {{ item }} service
|
||||||
- Reload systemd configuration
|
ignore_errors: true
|
||||||
- Restart {{ item }} service
|
|
||||||
|
- name: "Install datasaker log agent"
|
||||||
|
apt:
|
||||||
|
name: "td-agent"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
when: '"dsk-log-agent" in datasaker_agents'
|
||||||
|
|
||||||
|
- name: Reload systemd configuration
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: True
|
||||||
|
|
||||||
|
- name: Restart dsk-agent service
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: true
|
||||||
|
state: restarted
|
||||||
|
with_items:
|
||||||
|
- "{{ datasaker_agents }}"
|
||||||
|
ignore_errors: true
|
||||||
@@ -9,20 +9,20 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ datasaker_docker_path }}/agent/dsk-log-agent"
|
- "{{ datasaker_docker_path }}/agent/dsk-log-agent"
|
||||||
|
|
||||||
- name: "Touch agent config"
|
- name: "create agent config"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ datasaker_docker_path }}/log-agent-config.yml"
|
path: "{{ datasaker_docker_path }}/dsk-docker-log-agent-config.yml"
|
||||||
state: touch
|
state: touch
|
||||||
|
|
||||||
- name: "Setting dsk-log-agent config"
|
- name: "Setting dsk-log-agent config"
|
||||||
template:
|
template:
|
||||||
src: log-agent-config.yml.j2
|
src: docker-log-agent-config.yml.j2
|
||||||
dest: "{{ datasaker_docker_path }}/log-agent-config.yml"
|
dest: "{{ datasaker_docker_path }}/dsk-docker-log-agent-config.yml"
|
||||||
|
|
||||||
- name: Run Datasaker Log Agent
|
- name: Run Datasaker Log Agent
|
||||||
docker_container:
|
docker_container:
|
||||||
name: dsk-docker-log-agent
|
name: dsk-docker-log-agent
|
||||||
image: "datasaker/dsk-log-agent:{{ trace_agent_image_tag }}"
|
image: "datasaker/dsk-log-agent:{{ log_agent_image_tag }}"
|
||||||
state: started
|
state: started
|
||||||
detach: true
|
detach: true
|
||||||
restart_policy: "{{ log_agent_restart_policy }}"
|
restart_policy: "{{ log_agent_restart_policy }}"
|
||||||
@@ -32,6 +32,6 @@
|
|||||||
volumes:
|
volumes:
|
||||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||||
- "{{ datasaker_docker_path }}/log-agent-config.yml:/etc/datasaker/dsk-log-agent/agent-config.yml:ro"
|
- "{{ datasaker_docker_path }}/dsk-docker-log-agent-config.yml:/etc/datasaker/dsk-log-agent/agent-config.yml:ro"
|
||||||
- "{{ item }}"
|
- "{{ item }}"
|
||||||
loop: "{{ custom_log_volume | default(['{{ docker_default_path }}:/var/log/sample/:ro']) }}"
|
loop: "{{ custom_log_volume | default(['{{ docker_default_path }}:/var/log/sample/:ro']) }}"
|
||||||
|
|||||||
@@ -10,20 +10,20 @@
|
|||||||
- "{{ datasaker_docker_path }}/agent/dsk-postgres-agent"
|
- "{{ datasaker_docker_path }}/agent/dsk-postgres-agent"
|
||||||
- "{{ datasaker_docker_path }}/agent/dsk-plan-postgres-agent"
|
- "{{ datasaker_docker_path }}/agent/dsk-plan-postgres-agent"
|
||||||
|
|
||||||
- name: "Touch agent config"
|
- name: "Create agent config"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ datasaker_docker_path }}/dsk-postgres-config.yml"
|
path: "{{ datasaker_docker_path }}/dsk-docker-postgres-config.yml"
|
||||||
state: touch
|
state: touch
|
||||||
|
|
||||||
- name: "Setting dsk-postgres-agent config"
|
- name: "Setting dsk-postgres-agent config"
|
||||||
template:
|
template:
|
||||||
src: docker-postgres-agent-config.yml.j2
|
src: docker-postgres-agent-config.yml.j2
|
||||||
dest: "{{ datasaker_docker_path }}/dsk-postgres-config.yml"
|
dest: "{{ datasaker_docker_path }}/dsk-docker-postgres-config.yml"
|
||||||
|
|
||||||
- name: "Setting plan-dsk-postgres-agent config"
|
- name: "Setting plan-dsk-postgres-agent config"
|
||||||
template:
|
template:
|
||||||
src: plan-postgres-agent-config.yml.j2
|
src: docker-plan-postgres-agent-config.yml.j2
|
||||||
dest: "{{ datasaker_docker_path }}/dsk-plan-postgres-config.yml"
|
dest: "{{ datasaker_docker_path }}/dsk-docker-plan-postgres-config.yml"
|
||||||
|
|
||||||
- name: "Run dsk-postgres-agent container"
|
- name: "Run dsk-postgres-agent container"
|
||||||
docker_container:
|
docker_container:
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
volumes:
|
volumes:
|
||||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||||
- "{{ datasaker_docker_path }}/dsk-postgres-config.yml:/etc/datasaker/dsk-postgres-agent/agent-config.yml:ro"
|
- "{{ datasaker_docker_path }}/dsk-docker-postgres-config.yml:/etc/datasaker/dsk-postgres-agent/agent-config.yml:ro"
|
||||||
|
|
||||||
- name: "Run dsk-plan-postgres-agent container"
|
- name: "Run dsk-plan-postgres-agent container"
|
||||||
docker_container:
|
docker_container:
|
||||||
@@ -54,4 +54,4 @@
|
|||||||
volumes:
|
volumes:
|
||||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||||
- "{{ datasaker_docker_path }}/dsk-plan-postgres-config.yml:/etc/datasaker/dsk-plan-postgres-agent/agent-config.yml:ro"
|
- "{{ datasaker_docker_path }}/dsk-docker-plan-postgres-config.yml:/etc/datasaker/dsk-plan-postgres-agent/agent-config.yml:ro"
|
||||||
|
|||||||
@@ -9,15 +9,15 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ datasaker_docker_path }}/agent/dsk-trace-agent"
|
- "{{ datasaker_docker_path }}/agent/dsk-trace-agent"
|
||||||
|
|
||||||
- name: "Touch agent config"
|
- name: "Create agent config"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ datasaker_docker_path }}/trace-agent-config.yml"
|
path: "{{ datasaker_docker_path }}/dsk-docker-trace-agent-config.yml"
|
||||||
state: touch
|
state: touch
|
||||||
|
|
||||||
- name: "Setting dsk-trace-agent config"
|
- name: "Setting dsk-trace-agent config"
|
||||||
template:
|
template:
|
||||||
src: trace-agent-config.yml.j2
|
src: trace-agent-config.yml.j2
|
||||||
dest: "{{ datasaker_docker_path }}/trace-agent-config.yml"
|
dest: "{{ datasaker_docker_path }}/dsk-docker-trace-agent-config.yml"
|
||||||
|
|
||||||
- name: "Run Datasaker trace Agent"
|
- name: "Run Datasaker trace Agent"
|
||||||
ansible.builtin.docker_container:
|
ansible.builtin.docker_container:
|
||||||
@@ -34,4 +34,4 @@
|
|||||||
volumes:
|
volumes:
|
||||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||||
- "{{ datasaker_docker_path }}/trace-agent-config.yml:/etc/datasaker/dsk-trace-agent/agent-config.yml:ro"
|
- "{{ datasaker_docker_path }}/dsk-docker-trace-agent-config.yml:/etc/datasaker/dsk-trace-agent/agent-config.yml:ro"
|
||||||
|
|||||||
@@ -28,6 +28,13 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ datasaker_agents }}"
|
- "{{ datasaker_agents }}"
|
||||||
|
|
||||||
|
- name: "Install datasaker log agent"
|
||||||
|
apt:
|
||||||
|
name: "td-agent"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
when: '"dsk-log-agent" in datasaker_agents'
|
||||||
|
|
||||||
- name: "Install datasaker agent"
|
- name: "Install datasaker agent"
|
||||||
yum:
|
yum:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
@@ -38,3 +45,4 @@
|
|||||||
notify:
|
notify:
|
||||||
- Reload systemd configuration
|
- Reload systemd configuration
|
||||||
- Restart {{ item }} service
|
- Restart {{ item }} service
|
||||||
|
ignore_errors: true
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
- datasaker_agents
|
- datasaker_agents
|
||||||
|
|
||||||
- name: Stop agent service
|
- name: Stop agent service
|
||||||
service:
|
ansible.builtin.systemd:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
enabled: true
|
enabled: true
|
||||||
state: stopped
|
state: stopped
|
||||||
@@ -36,9 +36,26 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ datasaker_agents }}"
|
- "{{ datasaker_agents }}"
|
||||||
when:
|
when:
|
||||||
|
- ansible_facts.os_family == "Debian"
|
||||||
- datasaker_agents
|
- datasaker_agents
|
||||||
|
notify:
|
||||||
|
- Reload systemd configuration
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: "Uninstall datasaker agent"
|
||||||
|
yum:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ datasaker_agents }}"
|
||||||
|
when:
|
||||||
|
- ansible_facts.os_family == "RedHat"
|
||||||
|
- datasaker_agents
|
||||||
|
notify:
|
||||||
|
- Reload systemd configuration
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
|
||||||
- name: Stop the Docker container
|
- name: Stop the Docker container
|
||||||
docker_container:
|
docker_container:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
|
|||||||
@@ -2,30 +2,31 @@ agent:
|
|||||||
metadata:
|
metadata:
|
||||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||||
collect:
|
collect:
|
||||||
{% for collect_item in log_collects %}
|
{% for collect_item in log_collects | default([{'paths': ['/var/log/sample/*/*.log'], 'exclude_paths': [], 'keywords': [], 'tag': 'Default', 'service': {'name': 'default', 'category': 'etc', 'type': 'etc'}}]) %}
|
||||||
- paths:
|
- paths:
|
||||||
{% for path in collect_item.paths %}
|
{% for path in collect_item.paths %}
|
||||||
- "{{ path | default('/var/log/sample/*/*.log') }}"
|
- "{{ path }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if collect_item.exclude_paths is defined %}
|
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
|
{% if collect_item.exclude_paths | default([]) %}
|
||||||
{% for exclude_path in collect_item.exclude_paths %}
|
{% for exclude_path in collect_item.exclude_paths %}
|
||||||
- "{{ exclude_path | default('[]') }}"
|
- "{{ exclude_path }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if collect_item.keywords is defined %}
|
|
||||||
keywords:
|
keywords:
|
||||||
|
{% if collect_item.keywords | default([]) %}
|
||||||
{% for keyword in collect_item.keywords %}
|
{% for keyword in collect_item.keywords %}
|
||||||
- "{{ keyword | default('[]') }}"
|
- "{{- keyword -}}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
tag: "{{ collect_item.tag | default('Default') }}"
|
{% if collect_item.tag is defined %}
|
||||||
|
tag: "{{ collect_item.tag }}"
|
||||||
|
{% endif %}
|
||||||
service:
|
service:
|
||||||
name: "{{ collect_item.service.name | default('default') }}"
|
name: "{{ collect_item.service.name }}"
|
||||||
category: "{{ collect_item.service.category | default('etc') }}"
|
category: "{{ collect_item.service.category }}"
|
||||||
type: "{{ collect_item.service.type | default('etc') }}"
|
type: "{{ collect_item.service.type }}"
|
||||||
{% if collect_item.service.address is defined %}
|
{% if collect_item.service.address is defined %}
|
||||||
address: "{{ collect_item.service.address }}"
|
address: "{{ collect_item.service.address }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
13
templates/docker-plan-postgres-agent-config.yml.j2
Normal file
13
templates/docker-plan-postgres-agent-config.yml.j2
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
agent:
|
||||||
|
metadata:
|
||||||
|
agent_name: "{{ plan_postgres_agent_name | default('dsk-plan-postgres-agent') }}"
|
||||||
|
data_source_name:
|
||||||
|
user: "{{ plan_postgres_user_name | default('') }}"
|
||||||
|
password: "{{ plan_postgres_user_password | default('') }}"
|
||||||
|
address: "{{ plan_postgres_database_address | default('') }}"
|
||||||
|
port: "{{ plan_postgres_database_port | default('') }}"
|
||||||
|
DBName: "{{ plan_postgres_database_name | default('') }}"
|
||||||
|
explain:
|
||||||
|
scrape_interval: {{ plan_postgres_scrape_interval | default('30s') }}
|
||||||
|
scrape_timeout: {{ plan_postgres_scrape_timeout | default('5s') }}
|
||||||
|
slow_query_standard: {{ plan_postgres_slow_query_standard | default('5s') }}
|
||||||
@@ -2,30 +2,31 @@ agent:
|
|||||||
metadata:
|
metadata:
|
||||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||||
collect:
|
collect:
|
||||||
{% for collect_item in log_collects %}
|
{% for collect_item in log_collects | default([{'paths': ['/var/log/*.log'], 'exclude_paths': [], 'keywords': [], 'tag': 'Default', 'service': {'name': 'default', 'category': 'etc', 'type': 'etc'}}]) %}
|
||||||
- paths:
|
- paths:
|
||||||
{% for path in collect_item.paths %}
|
{% for path in collect_item.paths %}
|
||||||
- "{{ path | default('/var/log/*.log') }}"
|
- "{{ path }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if collect_item.exclude_paths is defined %}
|
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
|
{% if collect_item.exclude_paths | default([]) %}
|
||||||
{% for exclude_path in collect_item.exclude_paths %}
|
{% for exclude_path in collect_item.exclude_paths %}
|
||||||
- "{{ exclude_path | default('[]') }}"
|
- "{{ exclude_path }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if collect_item.keywords is defined %}
|
|
||||||
keywords:
|
keywords:
|
||||||
|
{% if collect_item.keywords | default([]) %}
|
||||||
{% for keyword in collect_item.keywords %}
|
{% for keyword in collect_item.keywords %}
|
||||||
- "{{ keyword | default('[]') }}"
|
- "{{- keyword -}}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
tag: "{{ collect_item.tag | default('Default') }}"
|
{% if collect_item.tag is defined %}
|
||||||
|
tag: "{{ collect_item.tag }}"
|
||||||
|
{% endif %}
|
||||||
service:
|
service:
|
||||||
name: "{{ collect_item.service.name | default('default') }}"
|
name: "{{ collect_item.service.name }}"
|
||||||
category: "{{ collect_item.service.category | default('etc') }}"
|
category: "{{ collect_item.service.category }}"
|
||||||
type: "{{ collect_item.service.type | default('etc') }}"
|
type: "{{ collect_item.service.type }}"
|
||||||
{% if collect_item.service.address is defined %}
|
{% if collect_item.service.address is defined %}
|
||||||
address: "{{ collect_item.service.address }}"
|
address: "{{ collect_item.service.address }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ agent:
|
|||||||
cluster_id: "{{ trace_agent_cluster_id | default('unknown_cluster') }}"
|
cluster_id: "{{ trace_agent_cluster_id | default('unknown_cluster') }}"
|
||||||
option:
|
option:
|
||||||
collector_config:
|
collector_config:
|
||||||
sampling_rate: "{{ trace_sampling_rate | default('10') }}"
|
sampling_rate: {{ trace_sampling_rate | default(10) | int }}
|
||||||
|
|||||||
Reference in New Issue
Block a user