Ansible Script 추가
This commit is contained in:
38
ansible/01_old/roles/datasaker/README.md
Normal file
38
ansible/01_old/roles/datasaker/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
34
ansible/01_old/roles/datasaker/defaults/main.yml
Normal file
34
ansible/01_old/roles/datasaker/defaults/main.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
# defaults file for datasaker
|
||||
|
||||
datagate_trace_url: 10.10.43.111
|
||||
datagate_trace_port: 31300
|
||||
datagate_trace_timeout: 5s
|
||||
|
||||
datagate_manifest_url: 10.10.43.111
|
||||
datagate_manifest_port: 31301
|
||||
datagate_manifest_timeout: 5s
|
||||
|
||||
datagate_metric_url: 10.10.43.111
|
||||
datagate_metric_port: 31302
|
||||
datagate_metric_timeout: 5s
|
||||
|
||||
datagate_plan_url: 10.10.43.111
|
||||
datagate_plan_port: 31303
|
||||
datagate_plan_timeout: 5s
|
||||
|
||||
datagate_loggate_url: 10.10.43.111
|
||||
datagate_loggate_port: 31304
|
||||
datagate_loggate_timeout: 5s
|
||||
|
||||
datasaker_api_url: 10.10.43.111:31501
|
||||
datasaker_api_send_interval: 1m
|
||||
|
||||
apt_trusted_d_keyring: "/etc/apt/trusted.gpg.d/datasaker-archive-keyring.gpg"
|
||||
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"
|
||||
|
||||
|
||||
datasaker_agents: []
|
||||
|
||||
34
ansible/01_old/roles/datasaker/handlers/main.yml
Normal file
34
ansible/01_old/roles/datasaker/handlers/main.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: Reload systemd configuration
|
||||
service:
|
||||
daemon_reload: True
|
||||
|
||||
- name: Restart dsk-trace-agent service
|
||||
service:
|
||||
name: dsk-trace-agent
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart dsk-node-agent service
|
||||
service:
|
||||
name: dsk-node-agent
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart dsk-log-agent service
|
||||
service:
|
||||
name: dsk-log-agent
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart dsk-postgres-agent service
|
||||
service:
|
||||
name: dsk-postgres-agent
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart dsk-plan-postgres-agent service
|
||||
service:
|
||||
name: dsk-plan-postgres-agent
|
||||
enabled: true
|
||||
state: restarted
|
||||
20
ansible/01_old/roles/datasaker/tasks/check-agent.yml
Normal file
20
ansible/01_old/roles/datasaker/tasks/check-agent.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Check dsk-node-agent
|
||||
include_tasks: dsk-node-agent.yml
|
||||
when: '"dsk-node-agent" in datasaker_agents'
|
||||
|
||||
- name: Check dsk-trace-agent
|
||||
include_tasks: dsk-trace-agent.yml
|
||||
when: '"dsk-trace-agent" in datasaker_agents'
|
||||
|
||||
- name: Check dsk-log-agent
|
||||
include_tasks: dsk-log-agent.yml
|
||||
when: '"dsk-log-agent" in datasaker_agents'
|
||||
|
||||
- name: Check dsk-postgres-agent
|
||||
include_tasks: dsk-postgres-agent.yml
|
||||
when: '"dsk-postgres-agent" in datasaker_agents'
|
||||
|
||||
- name: Check dsk-plan-postgres-agent
|
||||
include_tasks: dsk-plan-postgres-agent.yml
|
||||
when: '"dsk-plan-postgres-agent" in datasaker_agents'
|
||||
10
ansible/01_old/roles/datasaker/tasks/dsk-common.yml
Normal file
10
ansible/01_old/roles/datasaker/tasks/dsk-common.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Make Datasaker Directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- /etc/datasaker
|
||||
60
ansible/01_old/roles/datasaker/tasks/dsk-debian-pkg.yml
Normal file
60
ansible/01_old/roles/datasaker/tasks/dsk-debian-pkg.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
- name: "Setting global-config"
|
||||
template:
|
||||
src: global-config.yml.j2
|
||||
dest: "/etc/datasaker/global-config.yml"
|
||||
|
||||
- name: "Create temporary directory for key manipulation"
|
||||
tempfile:
|
||||
state: directory
|
||||
suffix: keys
|
||||
register: tempdir
|
||||
|
||||
- name: "download keyring then add key to keyring"
|
||||
get_url:
|
||||
url: "{{ dsk_public_gpg_key }}"
|
||||
dest: "{{ tempdir.path }}/datasaker.gpg.key"
|
||||
force: yes
|
||||
|
||||
- name: "Ensure downloaded file for binary keyring"
|
||||
shell: "cat {{ tempdir.path }}/datasaker.gpg.key | sudo gpg --import --batch --no-default-keyring --keyring {{ apt_usr_share_keyring }}"
|
||||
|
||||
- name: "copy keyring to trusted keyring"
|
||||
copy:
|
||||
src: "{{ apt_usr_share_keyring }}"
|
||||
dest: "{{ apt_trusted_d_keyring }}"
|
||||
mode: "0600"
|
||||
remote_src: yes
|
||||
|
||||
- name: "Remove temporary directory for key manipulation"
|
||||
file:
|
||||
path: "{{ tempdir.path }}"
|
||||
state: absent
|
||||
|
||||
- name: "Add datasaker repository"
|
||||
apt_repository:
|
||||
repo: "deb [signed-by={{ apt_usr_share_keyring }}] https://nexus.exem-oss.org/repository/debian-repos/ ubuntu main"
|
||||
state: present
|
||||
filename: datasaker.list
|
||||
|
||||
- name: "Check datasaker Agent"
|
||||
include_tasks: check-agent.yml
|
||||
|
||||
- name: "Install datasaker agent"
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- "{{ datasaker_agents }}"
|
||||
notify:
|
||||
- Restart {{ item }} service
|
||||
|
||||
# - name: "Ensure datasaker agent is running"
|
||||
# service:
|
||||
# name: "{{ item }}"
|
||||
# state: started
|
||||
# enabled: yes
|
||||
# with_items:
|
||||
# - "{{ datasaker_agents }}"
|
||||
|
||||
15
ansible/01_old/roles/datasaker/tasks/dsk-log-agent.yml
Normal file
15
ansible/01_old/roles/datasaker/tasks/dsk-log-agent.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Make agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "/etc/datasaker/{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "dsk-log-agent"
|
||||
|
||||
- name: "Setting dsk-log-agent config"
|
||||
template:
|
||||
src: log-agent-config.yml.j2
|
||||
dest: "/etc/datasaker/dsk-log-agent/agent-config.yml"
|
||||
15
ansible/01_old/roles/datasaker/tasks/dsk-node-agent.yml
Normal file
15
ansible/01_old/roles/datasaker/tasks/dsk-node-agent.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Make agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "/etc/datasaker/{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "dsk-node-agent"
|
||||
|
||||
- name: "Setting dsk-node-agent config"
|
||||
template:
|
||||
src: node-agent-config.yml.j2
|
||||
dest: "/etc/datasaker/dsk-node-agent/agent-config.yml"
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Make agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "/etc/datasaker/{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "dsk-plan-postgres-agent"
|
||||
|
||||
- name: "Setting dsk-plan-postgres-agent config"
|
||||
template:
|
||||
src: plan-postgres-agent-config.yml.j2
|
||||
dest: "/etc/datasaker/dsk-plan-postgres-agent/agent-config.yml"
|
||||
15
ansible/01_old/roles/datasaker/tasks/dsk-trace-agent.yml
Normal file
15
ansible/01_old/roles/datasaker/tasks/dsk-trace-agent.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Make agent Directory
|
||||
ansible.builtin.file:
|
||||
path: "/etc/datasaker/{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "dsk-trace-agent"
|
||||
|
||||
- name: "Setting dsk-trace-agent config"
|
||||
template:
|
||||
src: trace-agent-config.yml.j2
|
||||
dest: "/etc/datasaker/dsk-trace-agent/agent-config.yml"
|
||||
3
ansible/01_old/roles/datasaker/tasks/gather-facts.yml
Normal file
3
ansible/01_old/roles/datasaker/tasks/gather-facts.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: Gather Ansible Facts
|
||||
ansible.builtin.setup:
|
||||
12
ansible/01_old/roles/datasaker/tasks/main copy.yml
Normal file
12
ansible/01_old/roles/datasaker/tasks/main copy.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Include Gather Ansible Facts task on Ansible >= 2.10
|
||||
include_tasks: gather-facts.yml
|
||||
when: ansible_version.major >= 2 and ansible_version.minor >= 10
|
||||
|
||||
- name: Include Datasaker Add Repository
|
||||
include_tasks: dsk-common.yml
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
|
||||
- name: Include Datasaker Host Agent Install
|
||||
include_tasks: dsk-debian-pkg.yml
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
12
ansible/01_old/roles/datasaker/tasks/main.yml
Normal file
12
ansible/01_old/roles/datasaker/tasks/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Include Gather Ansible Facts task on Ansible >= 2.10
|
||||
include_tasks: gather-facts.yml
|
||||
when: ansible_version.major >= 2 and ansible_version.minor >= 10
|
||||
|
||||
- name: Include Datasaker Add Repository
|
||||
include_tasks: dsk-common.yml
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
|
||||
- name: Include Datasaker Host Agent Install
|
||||
include_tasks: dsk-debian-pkg.yml
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
@@ -0,0 +1,22 @@
|
||||
global:
|
||||
api_key: {{ datasaker_api_key }}
|
||||
gates:
|
||||
trace_datagate:
|
||||
url: {{ datagate_trace_url }}:{{ datagate_trace_port }}
|
||||
remote_timeout: {{ datagate_trace_timeout }}
|
||||
manifest_datagate:
|
||||
url: {{ datagate_manifest_url }}:{{ datagate_manifest_port }}
|
||||
remote_timeout: {{ datagate_manifest_timeout }}
|
||||
metric_datagate:
|
||||
url: {{ datagate_metric_url }}:{{ datagate_metric_port }}
|
||||
remote_timeout: {{ datagate_metric_timeout }}
|
||||
plan_datagate:
|
||||
url: {{ datagate_plan_url }}:{{ datagate_plan_port }}
|
||||
remote_timeout: {{ datagate_plan_timeout }}
|
||||
loggate:
|
||||
url: {{ datagate_loggate_url }}:{{ datagate_loggate_port }}
|
||||
remote_timeout: {{ datagate_loggate_timeout }}
|
||||
agent_manager:
|
||||
url: {{ datasaker_api_url }}
|
||||
base_url: /dsk-agentmanager-api/agent
|
||||
send_interval: {{ datasaker_api_send_interval }}
|
||||
@@ -0,0 +1,35 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||
cluster_id: "{{ log_agent_cluster_id | default('unknown') }}"
|
||||
environment: "{{ log_agent_environment | default('etc') }}"
|
||||
collect:
|
||||
- paths:
|
||||
{% if paths is defined and paths | length > 0 %}
|
||||
{% for path in paths %}
|
||||
- "{{ path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
- /var/log/*/*.log
|
||||
{% endif %}
|
||||
{% if exclude_paths is defined and exclude_paths | length > 0 %}
|
||||
exclude_paths:
|
||||
{% for exclude_path in exclude_paths %}
|
||||
- "{{ exclude_path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
exclude_paths: []
|
||||
{% endif %}
|
||||
{% if keywords is defined and keywords | length > 0 %}
|
||||
keywords:
|
||||
{% for keyword in keywords %}
|
||||
- "{{ keyword | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
keywords: []
|
||||
{% endif %}
|
||||
tag: "{{ log_agent_tag | default('sample') }}"
|
||||
service:
|
||||
name: "{{ log_agent_service_name | default('test') }}"
|
||||
category: "{{ log_agent_service_category | default('etc') }}"
|
||||
type: "{{ log_agent_service_type | default('etc') }}"
|
||||
@@ -0,0 +1,37 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||
cluster_id: "{{ log_agent_cluster_id | default('unknown') }}"
|
||||
environment: "{{ log_agent_environment | default('etc') }}"
|
||||
collect:
|
||||
- paths:
|
||||
{% if paths is defined and paths | length > 0 %}
|
||||
{% for path in paths %}
|
||||
- "{{ path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
- /var/log/*/*.log
|
||||
{% endif %}
|
||||
|
||||
{% if exclude_paths is defined and exclude_paths | length > 0 %}
|
||||
exclude_paths:
|
||||
{% for exclude_path in exclude_paths %}
|
||||
- "{{ exclude_path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
exclude_paths: []
|
||||
{% endif %}
|
||||
|
||||
{% if keywords is defined and keywords | length > 0 %}
|
||||
keywords:
|
||||
{% for keyword in keywords %}
|
||||
- "{{ keyword | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
keywords: []
|
||||
{% endif %}
|
||||
tag: "{{ log_agent_tag | default('sample') }}"
|
||||
service:
|
||||
name: "{{ log_agent_service_name | default('test') }}"
|
||||
category: "{{ log_agent_service_category | default('etc') }}"
|
||||
type: "{{ log_agent_service_type | default('etc') }}"
|
||||
@@ -0,0 +1,18 @@
|
||||
agent:
|
||||
metadata:
|
||||
# agent_name: my-dsk-node-agent
|
||||
# cluster_id: my-cluster
|
||||
option:
|
||||
exporter_config:
|
||||
command: "dsk-node-exporter"
|
||||
port: 19110
|
||||
args:
|
||||
- --collector.filesystem.ignored-mount-points="^/(dev|proc|sys|run|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)"
|
||||
- --collector.tcpstat
|
||||
scrape_interval: 15s
|
||||
scrape_timeout: 5s
|
||||
scrape_configs:
|
||||
- job_name: dsk-node-agent
|
||||
url: localhost:19110
|
||||
filtering_configs:
|
||||
rule: drop
|
||||
@@ -0,0 +1,18 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ plan_postgres_agent_name | default('dsk-plan-postgres-agent') }}"
|
||||
cluster_id: "{{ plan_postgres_agent_cluster_id | default('REPLACE_CLUSTER_ID') }}"
|
||||
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') }}"
|
||||
executor_number: "{{ plan_postgres_executor_number | default('10') }}"
|
||||
sender_number: "{{ plan_postgres_sender_number | default('10') }}"
|
||||
activity_query_buffer: "{{ plan_postgres_activity_query_buffer | default('50') }}"
|
||||
plan_sender_buffer: "{{ plan_postgres_plan_sender_buffer | default('50') }}"
|
||||
@@ -0,0 +1,5 @@
|
||||
agent:
|
||||
metadata:
|
||||
option:
|
||||
agent_name: "{{ trace_agent_name | default('trace-agent') }}"
|
||||
cluster_id: "{{ trace_agent_cluster_id | default('unknown_cluster') }}"
|
||||
Reference in New Issue
Block a user