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 all commits
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-*
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
# 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
### General
* Ansible >= 2.15.0
### Windows
* 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 ; sys_platform == 'win32'
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 (see [Direct download from your environment](#direct-download-from-your-environment)).
| `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
2 changes: 1 addition & 1 deletion roles/oneagent/tasks/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Combine configuration parameters
ansible.builtin.set_fact:
_oneagent_all_config_args: "{{ oneagent_passed_install_args | map('regex_search', '(--set-(.*))') | select('string') | list }} --restart-service"
_oneagent_all_config_args: "{{ oneagent_passed_install_args | map('regex_search', '(--set-(.*))') | select('string') | list + ['--restart-service'] }}"
no_log: true

- name: Apply OneAgent configuration
Expand Down
4 changes: 2 additions & 2 deletions roles/oneagent/tasks/install/post-install-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
ansible.builtin.reboot:
reboot_timeout: oneagent_reboot_timeout
register: _oneagent_reboot_status
when: oneagent_reboot_host
when: oneagent_reboot_host | bool

- name: Check the host reboot status
ansible.builtin.fail:
msg: "{{ oneagent_reboot_failed }}"
when: oneagent_reboot_host and not _oneagent_reboot_status.rebooted|default(false)
when: oneagent_reboot_host | bool and not _oneagent_reboot_status.rebooted|default(false)
4 changes: 2 additions & 2 deletions roles/oneagent/tasks/install/post-install-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
win_reboot:
reboot_timeout: oneagent_reboot_timeout
register: _oneagent_reboot_status
when: oneagent_reboot_host
when: oneagent_reboot_host | bool

- name: Check the host reboot status
ansible.builtin.fail:
msg: "{{ oneagent_reboot_failed }}"
when: oneagent_reboot_host and not _oneagent_reboot_status.rebooted|default(false)
when: oneagent_reboot_host | bool and not _oneagent_reboot_status.rebooted|default(false)
2 changes: 1 addition & 1 deletion roles/oneagent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
always:
- name: Cleanup
ansible.builtin.include_tasks: cleanup/cleanup.yml
when: oneagent_is_operation_installation and not oneagent_preserve_installer
when: oneagent_is_operation_installation and not (oneagent_preserve_installer | bool)

- name: Uninstall OneAgent
ansible.builtin.include_tasks: uninstall/uninstall.yml
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
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)
6 changes: 2 additions & 4 deletions roles/oneagent/vars/aix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ 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
6 changes: 2 additions & 4 deletions roles/oneagent/vars/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ 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 }}'\""
6 changes: 2 additions & 4 deletions roles/oneagent/vars/win32nt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ 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