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

Fix ansible-lint errors #62

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 4 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- .github
- .pre-commit-config.yaml
- .gitignore
- venv
4 changes: 1 addition & 3 deletions roles/oneagent/examples/advanced_config/advanced_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -22,4 +20,4 @@
tasks:
- name: Import Dynatrace OneAgent role
ansible.builtin.import_role:
name: oneagent
name: dynatrace.oneagent.oneagent
4 changes: 1 addition & 3 deletions roles/oneagent/examples/local_installer/local_installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,4 +10,4 @@
tasks:
- name: Import Dynatrace OneAgent role
ansible.builtin.import_role:
name: oneagent
name: dynatrace.oneagent.oneagent
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -61,6 +61,7 @@ deployUninstallScript() {
}

applyConfig() {
# shellcheck disable=SC2086
"${INSTALL_DIR}/agent/tools/${ONEAGENTCTL_BIN}" ${CTL_PARAMS}
}

Expand Down
9 changes: 4 additions & 5 deletions roles/oneagent/tests/resources/installers/oneagentctl.sh
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
Expand All @@ -36,6 +34,7 @@ saveToConfig() {
}

readFromConfig() {
# shellcheck disable=SC2155
local getterType="$(cutVariable "${1}" "-" "5-")"

if [ "${getterType}" = "properties" ]; then
Expand All @@ -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
Expand Down
Loading