Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Ansible collection to the newest version #38

Merged
merged 8 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dynatrace-oneagent-*
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# Dynatrace OneAgent collection

In its current state, collection consist of a single role that deploys Dynatrace OneAgent on Linux and Windows operating systems using dedicated configuration and ensures the OneAgent service maintains a running state.
In its current state, the collection consists of a single role that deploys Dynatrace OneAgent on Linux and Windows operating systems using dedicated configuration and ensures the OneAgent service maintains a running state.

## Requirements
* Ansible >= 2.15.0
* pywinrm >= 0.4.1
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved

Using this collection requires the following:
## Setup
`pip install -r requirements.txt`

* Ansible >= 2.9.0
* pywinrm >= 0.4.1
## Build
`ansible-galaxy collection build .`

## Installation
To install the latest stable release of the collection on your system, call:
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved

Use `ansible-galaxy collection install dynatrace.oneagent` to install the latest stable release of the collection on your system.
`ansible-galaxy collection install dynatrace.oneagent`

## License
To install the locally built collection on your system, call:

`ansible-galaxy collection install dynatrace-oneagent-<version>.tar.gz`

## License
Licensed under the MIT License.

## Support

In case of difficulties, contact our [SUPPORT].

[SUPPORT]: https://www.dynatrace.com/support/contact-support/
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
# Required version of ansible-core to use the collection
requires_ansible: ">=2.14.0"
requires_ansible: ">=2.15.0"
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ansible >= 2.15.0
pywinrm >= 0.4.1
2 changes: 1 addition & 1 deletion roles/oneagent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following variables are available in `defaults/main/` and can be overridden:

| Name | Default | Description
|-|-|-
| `oneagent_environment_url` | `-` | The URL of the target Dynatrace environment (SaaS or Managed).
| `oneagent_environment_url` | `-` | The URL of the target Dynatrace environment (SaaS or Managed) in `https://<environment_uuid>.dev.dynatracelabs.com` format.
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved
| `oneagent_paas_token` | `-` | The [PaaS Token] retrieved from the "Deploy Dynatrace" installer page.
| `oneagent_local_installer` | `-` | The Path to OneAgent installer stored on the main node.
| `oneagent_installer_arch` | `-` | Specifies the OneAgent installer architecture.
Expand Down
3 changes: 2 additions & 1 deletion roles/oneagent/tasks/params/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
msg: "{{ oneagent_unknown_arch | format(oneagent_download_arch, oneagent_available_arch) }}"
when: oneagent_is_operation_installation and not oneagent_download_arch in oneagent_available_arch

- ansible.builtin.include_tasks: tasks/params/params-{{ oneagent_system_family }}.yml

- name: Validate OneAgent installer version parameter
ansible.builtin.include_tasks: tasks/params/params-{{ oneagent_system_family }}.yml
ansible.builtin.fail:
msg: "{{ oneagent_version_lower_than_minimal | format(oneagent_version, oneagent_minimal_install_version) }}"
when: oneagent_is_operation_installation and oneagent_version != 'latest' and oneagent_version < oneagent_minimal_install_version
Expand Down
2 changes: 1 addition & 1 deletion roles/oneagent/tasks/provide-installer/download-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ansible.builtin.get_url:
url: "{{ _oneagent_installer_url }}"
dest: "{{ oneagent_installer_path }}"
validate_certs: "{{ oneagent_validate_certs | bool }}"
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved
validate_certs: "{{ oneagent_validate_certs }}"
mode: "0755"
headers:
Authorization: Api-Token {{ oneagent_paas_token }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
win_get_url:
url: "{{ _oneagent_installer_url }}"
dest: "{{ oneagent_installer_path }}"
validate_certs: "{{ oneagent_validate_certs | bool }}"
validate_certs: "{{ oneagent_validate_certs }}"
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved
headers:
Authorization: Api-Token {{ oneagent_paas_token }}
no_log: true
Expand Down
3 changes: 2 additions & 1 deletion roles/oneagent/tasks/provide-installer/download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"#VER": "{{ (oneagent_version == 'latest') | ternary('', 'version/') + oneagent_version }}"
"#ARCH": "{{ oneagent_download_arch }}"

- ansible.builtin.include_tasks: provide-installer/download-{{ oneagent_system_family }}.yml

- name: Verify download result
ansible.builtin.include_tasks: provide-installer/download-{{ oneagent_system_family }}.yml
ansible.builtin.fail:
msg: "{{ oneagent_failed_download | format(_oneagent_download_result.response | default(_oneagent_download_result.msg)) }}"
when: _oneagent_download_result.failed|default(false)
7 changes: 3 additions & 4 deletions roles/oneagent/vars/aix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ oneagent_default_install_dir: /opt/dynatrace/oneagent
oneagent_default_download_dir: "{{ ansible_env['TEMP'] | default('/tmp') }}"

oneagent_download_system: aix
oneagent_available_arch: "{{ [ oneagent_default_arch ] }}"
filip-szweda marked this conversation as resolved.
Show resolved Hide resolved
oneagent_available_arch:
- "{{ oneagent_default_arch }}"
oneagent_download_arch: "{{ oneagent_installer_arch | default(oneagent_default_arch, true) }}"

oneagent_install_path: >
"{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first |
default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)', '\\1') }}"
oneagent_install_path: "{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first | default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)', '\\1') }}"
oneagent_download_path: "{{ oneagent_download_dir | default(oneagent_default_download_dir, true) }}"
oneagent_installer_path: "{{ oneagent_download_path }}/Dynatrace-OneAgent-AIX-{{ oneagent_version }}.sh"
oneagent_ctl_bin_path: "{{ oneagent_install_path }}/agent/tools/oneagentctl"
Expand Down
10 changes: 6 additions & 4 deletions roles/oneagent/vars/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ oneagent_default_install_dir: /opt/dynatrace/oneagent
oneagent_default_download_dir: "{{ ansible_env['TEMP'] | default('/tmp') }}"

oneagent_download_system: unix
oneagent_available_arch: "{{ [ oneagent_default_arch, 'ppcle', 's390', 'arm' ] }}"
oneagent_available_arch:
- "{{ oneagent_default_arch }}"
- "ppcle"
- "s390"
- "arm"
oneagent_download_arch: "{{ oneagent_installer_arch | default(oneagent_default_arch, true) }}"

oneagent_install_path: >
"{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first | default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)',
'\\1') }}"
oneagent_install_path: "{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first | default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)','\\1') }}"
oneagent_download_path: "{{ oneagent_download_dir | default(oneagent_default_download_dir, true) }}"
oneagent_installer_arch_name: "{{ (oneagent_download_arch == oneagent_default_arch) | ternary('', oneagent_download_arch + '-') }}"
oneagent_installer_path: "{{ oneagent_download_path }}/Dynatrace-OneAgent-Linux-{{ oneagent_installer_arch_name }}{{ oneagent_version }}.sh"
Expand Down
15 changes: 7 additions & 8 deletions roles/oneagent/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ oneagent_system_is_windows: "{{ oneagent_system_name == 'win32nt' }}"
oneagent_system_family: "{{ oneagent_system_is_windows | ternary('windows', 'unix') }}"

oneagent_is_operation_uninstall: "{{ oneagent_package_state == 'absent' }}"
oneagent_is_operation_configuration: >
"{{ not oneagent_is_operation_uninstall and oneagent_environment_url|length == 0 and oneagent_paas_token|length == 0 and oneagent_local_installer|
length == 0 }}"
oneagent_is_operation_installation: "{{ not (oneagent_is_operation_uninstall or oneagent_is_operation_configuration) }}"
oneagent_is_operation_configuration: "{{ not oneagent_is_operation_uninstall and oneagent_environment_url|length == 0 and oneagent_paas_token|length == 0 and oneagent_local_installer|length == 0 }}"
oneagent_is_operation_installation: "{{ not (oneagent_is_operation_uninstall or oneagent_is_operation_configuration | bool) }}"

oneagent_passed_install_args: "{{ (oneagent_install_args + oneagent_platform_install_args) | unique }}"
oneagent_passed_install_args: "{{ (oneagent_install_args + oneagent_platform_install_args) | unique(case_sensitive=False) }}"
oneagent_default_download_url: "#URL/api/v1/deployment/installer/agent/#SYS/default/#VER?arch=#ARCH"
oneagent_additional_reporting_params: >
"{{ [ '--set-deployment-metadata=\"orchestration_tech=Ansible\"', '--set-deployment-metadata=\"tech_version=' + ansible_version.full
+ '\"', '--set-deployment-metadata=\"script_version=' + oneagent_script_version + '\"' ] }}"
oneagent_additional_reporting_params:
- "--set-deployment-metadata=\"orchestration_tech=Ansible\""
- "--set-deployment-metadata=\"tech_version='{{ ansible_version.full }}'\""
- "--set-deployment-metadata=\"script_version='{{ oneagent_script_version }}'\""
7 changes: 3 additions & 4 deletions roles/oneagent/vars/win32nt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ oneagent_default_install_dir: "{{ ansible_env.SystemDrive }}\\Program Files\\dyn
oneagent_default_download_dir: "{{ ansible_env['TEMP'] | default('C:\\Windows\\Temp') }}"

oneagent_download_system: windows
oneagent_available_arch: "{{ [ oneagent_default_arch ] }}"
oneagent_available_arch:
- "{{ oneagent_default_arch }}"
oneagent_download_arch: "{{ oneagent_installer_arch | default(oneagent_default_arch, true) }}"

oneagent_install_path: >
"{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first |
default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)', '\\1') }}"
oneagent_install_path: "{{ oneagent_passed_install_args | select('regex', 'INSTALL_PATH') | first | default(oneagent_default_install_dir) | regex_replace('INSTALL_PATH=(.*)', '\\1') }}"
oneagent_ctl_bin_path: "{{ oneagent_install_path }}\\agent\\tools\\oneagentctl.exe"
oneagent_download_path: "{{ oneagent_download_dir | default(oneagent_default_download_dir, true) }}"
oneagent_installer_path: "{{ oneagent_download_path }}\\Dynatrace-OneAgent-Windows-{{ oneagent_version }}.exe"
Expand Down