---
- name: Add the agent to the {{ dynatrace_java_agent_env_var_name }} environment variable definition in file {{ dynatrace_java_agent_env_var_file_name }}
  lineinfile: >
    dest={{ dynatrace_java_agent_env_var_file_name }}
    regexp='export {{ dynatrace_java_agent_env_var_name }}="\${{ dynatrace_java_agent_env_var_name }} {{ dynatrace_java_agent_agentpath_string }}"'
    line='export {{ dynatrace_java_agent_env_var_name }}="${{ dynatrace_java_agent_env_var_name }} {{ dynatrace_java_agent_agentpath_string }}"'
    insertbefore=BOF
    state={{ dynatrace_java_agent_state }}
    create=yes
  sudo: yes

---
- name: Add the agent to the {{ dynatrace_java_agent_env_var_name }} environment variable definition in file {{ dynatrace_java_agent_env_var_file_name }}
  lineinfile: >
    dest={{ dynatrace_java_agent_env_var_file_name }}
    regexp='export {{ dynatrace_java_agent_env_var_name }}="\${{ dynatrace_java_agent_env_var_name }} {{ dynatrace_java_agent_agentpath_string }}"'
    line='export {{ dynatrace_java_agent_env_var_name }}="${{ dynatrace_java_agent_env_var_name }} {{ dynatrace_java_agent_agentpath_string }}"'
    insertbefore=BOF
    state={{ dynatrace_java_agent_state }}
    create=yes
    backup=yes
  sudo: yes

Create backups for modified files.
Create backups for modified files.
