Ansible Script 추가

This commit is contained in:
ByeonJungHun
2023-12-19 13:36:16 +09:00
parent 0273450ff6
commit 05cb8d9269
2610 changed files with 281893 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
---
- name: Create main Datadog agent configuration file
win_template:
#FIXME: should have permissions set to only be readable by ddagentuser
src: datadog.yaml.j2
dest: "{{ datadog_windows_config_root }}\\datadog.yaml"
when: datadog_manage_config
notify: restart datadog-agent-win
- name: Register all checks directories present in datadog
win_find:
paths: "{{ ansible_facts.env['ProgramData'] }}\\Datadog\\conf.d"
patterns:
- "*.d"
file_type: directory
register: datadog_conf_directories
when: datadog_manage_config and (datadog_disable_untracked_checks or datadog_disable_default_checks)
- name: Delete checks not present in datadog_tracked_checks
win_file:
path: "{{ ansible_facts.env['ProgramData'] }}\\Datadog\\conf.d\\{{ item }}.d\\conf.yaml"
state: absent
loop: "{{ datadog_conf_directories.files | map(attribute='path') | list | map('win_basename') | list | map('regex_replace', '^(.*).d$', '\\1') | list }}"
when: datadog_manage_config and datadog_disable_untracked_checks and item not in datadog_tracked_checks
notify: restart datadog-agent-win
- name: Delete default checks
win_file:
path: "{{ ansible_facts.env['ProgramData'] }}\\Datadog\\conf.d\\{{ item }}.d\\conf.yaml.default"
state: absent
loop: "{{ datadog_conf_directories.files | map(attribute='path') | list | map('win_basename') | list | map('regex_replace', '^(.*).d$', '\\1') | list }}"
when: datadog_manage_config and datadog_disable_default_checks and item not in datadog_tracked_checks
notify: restart datadog-agent-win
- name: Ensure configuration directories are present for each Datadog check
win_file:
path: "{{ datadog_windows_config_root }}\\conf.d\\{{ item }}.d"
state: directory
with_items: '{{ datadog_checks|list }}'
when: datadog_manage_config
- name: Create a configuration file for each Datadog check
win_template:
src: checks.yaml.j2
dest: "{{ datadog_windows_config_root }}\\conf.d\\{{ item }}.d\\conf.yaml"
with_items: "{{ datadog_checks|list }}"
when: datadog_manage_config
notify: restart datadog-agent-win
- name: Remove old configuration file for each Datadog check
win_file:
path: "{{ datadog_windows_config_root }}\\conf.d\\{{ item }}.yaml"
state: absent
with_items: "{{ datadog_checks|list }}"
when: datadog_manage_config
notify: restart datadog-agent-win
- name: Create custom check file for each custom check
win_copy:
src: "{{ datadog_custom_checks[item] }}"
dest: "{{ datadog_windows_config_root }}\\checks.d\\{{ item }}.py"
with_items: "{{ datadog_custom_checks|list }}"
notify: restart datadog-agent-win
- name: Ensure datadog-trace-agent and datadog-process-agent are not disabled
win_service:
name: "{{ item }}"
start_mode: manual
when: not datadog_skip_running_check and datadog_enabled and not ansible_check_mode
with_list:
- datadog-trace-agent
- datadog-process-agent
- name: Create system-probe configuration file
win_template:
src: system-probe.yaml.j2
dest: "{{ datadog_windows_config_root }}\\system-probe.yaml"
when: datadog_manage_config
notify: restart datadog-agent-win
- name: Ensure datadog-agent is running
win_service:
name: datadogagent
state: started
start_mode: delayed
when: not datadog_skip_running_check and datadog_enabled and not ansible_check_mode
- name: Ensure datadog-agent is disabled
win_service:
name: "{{ item }}"
state: stopped
start_mode: disabled
when: not datadog_skip_running_check and not datadog_enabled
with_list:
- datadog-trace-agent
- datadog-process-agent
- datadogagent
- name: Create installation information file
template:
src: install_info.j2
dest: "{{ datadog_windows_config_root }}\\install_info"
mode: 0644