From 34e1ee74c1eb9417efa4faaff5b96f283f44e423 Mon Sep 17 00:00:00 2001 From: "wojciech.stechura" Date: Fri, 20 Dec 2024 11:23:51 +0100 Subject: [PATCH 1/3] Fix ansible-lint errors --- roles/oneagent/examples/advanced_config/advanced_config.yml | 4 +--- roles/oneagent/examples/local_installer/local_installer.yml | 4 +--- .../examples/oneagentctl_config/oneagentctl_config.yml | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/roles/oneagent/examples/advanced_config/advanced_config.yml b/roles/oneagent/examples/advanced_config/advanced_config.yml index 230d37d..e01f5da 100644 --- a/roles/oneagent/examples/advanced_config/advanced_config.yml +++ b/roles/oneagent/examples/advanced_config/advanced_config.yml @@ -3,8 +3,6 @@ Download OneAgent installer in specific version to a custom directory with additional OneAgent install parameters. Both linux_other and linux_arm have different user specified by platform args parameter. hosts: linux_other,linux_arm - collections: - - dynatrace.oneagent # credentials.yml file contains oneagent_environment_url and # oneagent_paas_token variables that needs to be stored securely vars_files: @@ -22,4 +20,4 @@ tasks: - name: Import Dynatrace OneAgent role ansible.builtin.import_role: - name: oneagent + name: dynatrace.oneagent.oneagent diff --git a/roles/oneagent/examples/local_installer/local_installer.yml b/roles/oneagent/examples/local_installer/local_installer.yml index fdc1237..7bf2bdc 100644 --- a/roles/oneagent/examples/local_installer/local_installer.yml +++ b/roles/oneagent/examples/local_installer/local_installer.yml @@ -3,9 +3,7 @@ Basic OneAgent installation using a local installer. Hosts placed in unix hosts groups have its local installer paths defined in inventory file. Main node communicates with Windows hosts over SSH. hosts: windows,unix - collections: - - dynatrace.oneagent tasks: - name: Import Dynatrace OneAgent role ansible.builtin.import_role: - name: oneagent + name: dynatrace.oneagent.oneagent diff --git a/roles/oneagent/examples/oneagentctl_config/oneagentctl_config.yml b/roles/oneagent/examples/oneagentctl_config/oneagentctl_config.yml index 343aed1..9308383 100644 --- a/roles/oneagent/examples/oneagentctl_config/oneagentctl_config.yml +++ b/roles/oneagent/examples/oneagentctl_config/oneagentctl_config.yml @@ -1,8 +1,6 @@ --- - name: Apply host level configuration with oneagentctl hosts: linux_other - collections: - - dynatrace.oneagent vars: oneagent_install_args: - --set-host-name=new_host_name @@ -12,4 +10,4 @@ tasks: - name: Import Dynatrace OneAgent role ansible.builtin.import_role: - name: oneagent + name: dynatrace.oneagent.oneagent From 39fec6a2d3660389338258cdfc17de8746bd3a0f Mon Sep 17 00:00:00 2001 From: "wojciech.stechura" Date: Fri, 3 Jan 2025 10:12:31 +0100 Subject: [PATCH 2/3] Update buildignore --- galaxy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/galaxy.yml b/galaxy.yml index d476328..445dcd2 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -16,5 +16,7 @@ tags: repository: https://github.com/Dynatrace/Dynatrace-OneAgent-Ansible documentation: https://docs.dynatrace.com/docs/setup-and-configuration/dynatrace-oneagent/deployment-orchestration/ansible build_ignore: - - roles/oneagent/tests - - roles/oneagent/examples \ No newline at end of file + - .github + - .pre-commit-config.yaml + - .gitignore + - venv \ No newline at end of file From 6d8d5fba30624b6121601fde790bf14b9ce29c27 Mon Sep 17 00:00:00 2001 From: "wojciech.stechura" Date: Fri, 3 Jan 2025 10:25:20 +0100 Subject: [PATCH 3/3] Fix shellcheck issues --- .../resources/installers/Dynatrace-OneAgent-Linux.sh | 7 ++++--- roles/oneagent/tests/resources/installers/oneagentctl.sh | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/oneagent/tests/resources/installers/Dynatrace-OneAgent-Linux.sh b/roles/oneagent/tests/resources/installers/Dynatrace-OneAgent-Linux.sh index 796e4a6..52a2a2c 100644 --- a/roles/oneagent/tests/resources/installers/Dynatrace-OneAgent-Linux.sh +++ b/roles/oneagent/tests/resources/installers/Dynatrace-OneAgent-Linux.sh @@ -1,20 +1,20 @@ -#!/bin/sh +#!/bin/bash -eu # This script acts as a self contained installer of the procuct -set -e - readonly DEFAULT_INSTALL_DIR="/opt/dynatrace/oneagent" readonly INSTALLER_VERSION="##VERSION##" readonly DEPLOYMENT_CONF_PATH="/var/lib/dynatrace/oneagent/agent/config" readonly UNINSTALL_SCRIPT="uninstall.sh" +# shellcheck disable=SC2155 readonly UNINSTALL_CODE="$(cat <<-ENDUNINSTALL ##UNINSTALL_CODE## ENDUNINSTALL )" readonly ONEAGENTCTL_BIN="oneagentctl" +# shellcheck disable=SC2155 readonly ONEAGENTCTL_CODE="$(cat <<-ENDCTL ##ONEAGENTCTL_CODE## ENDCTL @@ -61,6 +61,7 @@ deployUninstallScript() { } applyConfig() { + # shellcheck disable=SC2086 "${INSTALL_DIR}/agent/tools/${ONEAGENTCTL_BIN}" ${CTL_PARAMS} } diff --git a/roles/oneagent/tests/resources/installers/oneagentctl.sh b/roles/oneagent/tests/resources/installers/oneagentctl.sh index 08da32a..0914407 100644 --- a/roles/oneagent/tests/resources/installers/oneagentctl.sh +++ b/roles/oneagent/tests/resources/installers/oneagentctl.sh @@ -1,9 +1,6 @@ -#!/bin/bash +#!/bin/bash -eu # This file simulates deployment functionalities of oneagentctl binary, used to configure installation. - -set -e - readonly INSTALLER_VERSION="##VERSION##" readonly DEPLOYMENT_CONF_PATH="/var/lib/dynatrace/oneagent/agent/config" @@ -14,6 +11,7 @@ cutVariable() { printf "%s" "${variable}" | cut -d "${delimiter}" -f "${fields}" } +# shellcheck disable=SC2155 saveToConfig() { while [ $# -gt 0 ]; do # example command: --set-host-property=TENANT=tenant1 @@ -36,6 +34,7 @@ saveToConfig() { } readFromConfig() { + # shellcheck disable=SC2155 local getterType="$(cutVariable "${1}" "-" "5-")" if [ "${getterType}" = "properties" ]; then @@ -49,7 +48,7 @@ main() { if [ "${1}" = '--version' ]; then printf '%s\n' "${INSTALLER_VERSION}" elif printf "%s" "${1}" | grep -q "^--get"; then - readFromConfig ${1} + readFromConfig "${1}" elif printf "%s" "${1}" | grep -q "^--set"; then saveToConfig "$@" fi