Ansible Script 추가
This commit is contained in:
27
ansible/01_old/roles/datadog.datadog/handlers/main-macos.yml
Normal file
27
ansible/01_old/roles/datadog.datadog/handlers/main-macos.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
# This file doesn't actually contain "handlers" in the Ansible sense: when running
|
||||
# our role, Ansible only loads the contents of handlers/main.yml as handlers.
|
||||
# However, this is here because this is a "handler-like" task that is dynamically
|
||||
# included by a handler task in handlers/main.yml.
|
||||
|
||||
# NOTE: We don't use bootout/bootstrap here, because bootout can't wait for the operation
|
||||
# to finish and if it's in progress for a longer time, bootstrap fails. We use the old
|
||||
# unload/load combo because they actually wait.
|
||||
- name: Unload datadog-agent service
|
||||
command: "launchctl unload -wF {{ datadog_macos_system_plist_file_path }}"
|
||||
become: yes
|
||||
check_mode: no
|
||||
when: datadog_enabled and not ansible_check_mode and ansible_facts.os_family == "Darwin"
|
||||
|
||||
- name: Load datadog-agent service
|
||||
command: "launchctl load -wF {{ datadog_macos_system_plist_file_path }}"
|
||||
become: yes
|
||||
check_mode: no
|
||||
when: datadog_enabled and not ansible_check_mode and ansible_facts.os_family == "Darwin"
|
||||
|
||||
- name: Restart datadog-agent service
|
||||
command: "launchctl kickstart -k system/{{ datadog_macos_service_name }}"
|
||||
become: yes
|
||||
register: command_result
|
||||
check_mode: no
|
||||
when: datadog_enabled and not ansible_check_mode and ansible_facts.os_family == "Darwin"
|
||||
11
ansible/01_old/roles/datadog.datadog/handlers/main-win.yml
Normal file
11
ansible/01_old/roles/datadog.datadog/handlers/main-win.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
# This file doesn't actually contain "handlers" in the Ansible sense: when running
|
||||
# our role, Ansible only loads the contents of handlers/main.yml as handlers.
|
||||
# However, this is here because this is a "handler-like" task that is dynamically
|
||||
# included by a handler task in handlers/main.yml.
|
||||
- name: Restart Windows datadogagent service
|
||||
win_service:
|
||||
name: datadogagent
|
||||
state: restarted
|
||||
force_dependent_services: true
|
||||
when: datadog_enabled and not ansible_check_mode and ansible_facts.os_family == "Windows"
|
||||
31
ansible/01_old/roles/datadog.datadog/handlers/main.yml
Normal file
31
ansible/01_old/roles/datadog.datadog/handlers/main.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
|
||||
- name: restart datadog-agent-sysprobe
|
||||
service:
|
||||
name: datadog-agent-sysprobe
|
||||
state: restarted
|
||||
when: datadog_enabled and datadog_sysprobe_enabled and not ansible_check_mode and not ansible_facts.os_family == "Windows" and not ansible_facts.os_family == "Darwin"
|
||||
|
||||
- name: restart datadog-agent
|
||||
service:
|
||||
name: datadog-agent
|
||||
state: restarted
|
||||
when: datadog_enabled and not ansible_check_mode and not ansible_facts.os_family == "Windows" and not ansible_facts.os_family == "Darwin"
|
||||
|
||||
# We can't add the Windows Agent service restart handler directly here because that makes the role require
|
||||
# the ansible.windows collection on all platforms. We only want it to be needed on Windows.
|
||||
# Therefore, what we do is the following: when needed, our Windows tasks call this handler to require a
|
||||
# Windows Agent restart (through notify: restart datadog-agent-win).
|
||||
# When notified, the below handler is executed at the end of the playbook run.
|
||||
# The include_tasks loads the handlers/main-win.yml file, which contains the real service restart task
|
||||
# (which depends on ansible.windows), and runs it, triggering the Windows Agent restart.
|
||||
- name: restart datadog-agent-win
|
||||
include_tasks: handlers/main-win.yml
|
||||
|
||||
# When needed, our macOS tasks call this handler to require a
|
||||
# macOS Agent restart (through notify: restart datadog-agent-macos).
|
||||
# When notified, the below handler is executed at the end of the playbook run.
|
||||
# The include_tasks loads the handlers/main-macos.yml file, which contains the real service restart task
|
||||
# and runs it, triggering the macOS Agent restart.
|
||||
- name: restart datadog-agent-macos
|
||||
include_tasks: handlers/main-macos.yml
|
||||
Reference in New Issue
Block a user