136 lines
5.5 KiB
YAML
136 lines
5.5 KiB
YAML
|
|
---
|
||
|
|
- name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} agent."
|
||
|
|
ansible.builtin.get_url:
|
||
|
|
url: "{{ __checkmk_agent_agent.url.cre }}"
|
||
|
|
validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.cre }}"
|
||
|
|
mode: '0644'
|
||
|
|
timeout: "{{ checkmk_agent_download_timeout | default(omit) }}"
|
||
|
|
when: checkmk_agent_edition | lower == "cre"
|
||
|
|
register: __checkmk_agent_vanilla_download_state
|
||
|
|
retries: 3
|
||
|
|
delay: 10
|
||
|
|
until: "not __checkmk_agent_vanilla_download_state.failed | bool"
|
||
|
|
delegate_to: "{{ checkmk_agent_delegate_download }}"
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
ansible.builtin.uri:
|
||
|
|
url:
|
||
|
|
"{{ __checkmk_agent_agent.url.cee }}?\
|
||
|
|
host_name={{ checkmk_agent_host_name }}&\
|
||
|
|
os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\
|
||
|
|
agent_type=host_name"
|
||
|
|
validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.host }}"
|
||
|
|
method: GET
|
||
|
|
headers:
|
||
|
|
Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}"
|
||
|
|
Accept: "application/octet-stream"
|
||
|
|
timeout: "{{ checkmk_agent_download_timeout | default(omit) }}"
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower != "cre"
|
||
|
|
become: false
|
||
|
|
register: __checkmk_agent_host_download_state
|
||
|
|
# This task may fail, as we fall back to the generic agent in that case
|
||
|
|
failed_when: 'false'
|
||
|
|
changed_when: __checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200
|
||
|
|
delegate_to: "{{ checkmk_agent_delegate_download }}"
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Set Fact: Agent State: host-specific."
|
||
|
|
ansible.builtin.set_fact:
|
||
|
|
checkmk_agent_host_specific: >-
|
||
|
|
{{ (__checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200) | bool }}
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
ansible.builtin.uri:
|
||
|
|
url:
|
||
|
|
"{{ __checkmk_agent_agent.url.cee }}?\
|
||
|
|
os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\
|
||
|
|
folder_name={{ checkmk_agent_folder }}&\
|
||
|
|
agent_type=generic"
|
||
|
|
validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.cee }}"
|
||
|
|
method: GET
|
||
|
|
headers:
|
||
|
|
Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}"
|
||
|
|
Accept: "application/octet-stream"
|
||
|
|
timeout: "{{ checkmk_agent_download_timeout | default(omit) }}"
|
||
|
|
become: false
|
||
|
|
register: __checkmk_agent_folder_download_state
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower != "cre"
|
||
|
|
and checkmk_agent_folder is defined
|
||
|
|
and not checkmk_agent_host_specific | bool
|
||
|
|
retries: 3
|
||
|
|
failed_when: 'false'
|
||
|
|
changed_when: __checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200
|
||
|
|
delegate_to: "{{ checkmk_agent_delegate_download }}"
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific."
|
||
|
|
ansible.builtin.set_fact:
|
||
|
|
checkmk_agent_folder_specific: >-
|
||
|
|
{{ (__checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200) | bool }}
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
shell: |
|
||
|
|
curl -H "Accept: application/octet-stream" \
|
||
|
|
-H "Authorization: Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" \
|
||
|
|
{% if not checkmk_agent_server_validate_certs | bool %}--insecure{% endif %} \
|
||
|
|
{% if checkmk_agent_download_timeout is defined %}--max-time {{ checkmk_agent_download_timeout }}{% endif %} \
|
||
|
|
-o "{{ __checkmk_agent_agent.file.cee }}" \
|
||
|
|
"{{ __checkmk_agent_agent.url.cee }}?os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&agent_type=generic"
|
||
|
|
args:
|
||
|
|
creates: "{{ __checkmk_agent_agent.file.cee }}"
|
||
|
|
become: false
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower != "cre"
|
||
|
|
and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool)
|
||
|
|
retries: 3
|
||
|
|
delegate_to: "{{ checkmk_agent_delegate_download }}"
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ __checkmk_agent_agent.file.host }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.host }}"
|
||
|
|
mode: "0644"
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower != "cre"
|
||
|
|
and checkmk_agent_host_specific | bool
|
||
|
|
and checkmk_agent_delegate_download != inventory_hostname
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ __checkmk_agent_agent.file.cee }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.cee }}"
|
||
|
|
mode: "0644"
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower != "cre"
|
||
|
|
and not checkmk_agent_host_specific | bool
|
||
|
|
and checkmk_agent_delegate_download != inventory_hostname
|
||
|
|
tags:
|
||
|
|
- download-package
|
||
|
|
|
||
|
|
- name: "{{ ansible_system }}: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent."
|
||
|
|
ansible.builtin.copy:
|
||
|
|
src: "{{ __checkmk_agent_agent.file.cre }}"
|
||
|
|
dest: "{{ __checkmk_agent_agent.file.cre }}"
|
||
|
|
mode: "0644"
|
||
|
|
when: |
|
||
|
|
checkmk_agent_edition | lower == "cre"
|
||
|
|
and checkmk_agent_delegate_download != inventory_hostname
|
||
|
|
tags:
|
||
|
|
- download-package
|