Skip to content

Commit

Permalink
Merge pull request #5 from centic9/fix_ansible_2_1_and_make_idempotent
Browse files Browse the repository at this point in the history
Support Ansible < 2.3 and make it idempotent
  • Loading branch information
BlazejT authored Oct 23, 2017
2 parents 55071f3 + 824d826 commit 36553bc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
- name: Download Dynatrace OneAgent using token id
block:
- name: Check if Dynatrace OneAgent is already installed
stat:
path: /opt/dynatrace/oneagent/agent/lib64/liboneagentos.so
register: agent_installed

# only in Ansible >= 2.3.0: - name: Download Dynatrace OneAgent using token id
- block:
- fail:
msg: "The 'dynatrace_oneagent_cluster_subdomain' variable has not been set, it must point to the subdomain of your Dynatrace cluster. Please consult the documentation."
when: (dynatrace_oneagent_cluster_subdomain is undefined) or (dynatrace_oneagent_cluster_subdomain is none) or (dynatrace_oneagent_cluster_subdomain | trim == "")
Expand All @@ -20,19 +25,20 @@
url: "https://{{ dynatrace_oneagent_cluster_subdomain }}/e/{{ dynatrace_oneagent_environment_id }}/installer/agent/unix/latest/{{ dynatrace_oneagent_tenant_token }}"
dest: "/tmp/dynatrace-oneagent.sh"
when: ("live.dynatrace.com" != dynatrace_oneagent_cluster_subdomain) and ("live.ruxit.com" != dynatrace_oneagent_cluster_subdomain)
when: (oneagent_installer_script_url is undefined) or (oneagent_installer_script_url is none) or (oneagent_installer_script_url | trim == "")
when: agent_installed == False and ((oneagent_installer_script_url is undefined) or (oneagent_installer_script_url is none) or (oneagent_installer_script_url | trim == ""))

- name: Download Dynatrace OneAgent using installer script url
block:
# only in Ansible >= 2.3.0: - name: Download Dynatrace OneAgent using installer script url
- block:
- fail:
msg: "The 'oneagent_installer_script_url' variable has not been set, it must contain the Dynatrace OneAgent Installer Script URL. Please consult the documentation."
when: (oneagent_installer_script_url is undefined) or (oneagent_installer_script_url is none) or (oneagent_installer_script_url | trim == "")
- name: "Download Dynatrace OneAgent"
get_url:
url: "{{ oneagent_installer_script_url }}"
dest: "/tmp/dynatrace-oneagent.sh"
when: (oneagent_installer_script_url is defined) and (oneagent_installer_script_url is not none)
when: agent_installed.stat.exists == False and (oneagent_installer_script_url is defined) and (oneagent_installer_script_url is not none)

- name: "Install Dynatrace OneAgent"
shell: "sh /tmp/dynatrace-oneagent.sh"
become: yes
when: ansible_architecture != "armv7l" and agent_installed.stat.exists == False

0 comments on commit 36553bc

Please sign in to comment.