- name: "Inject the Dynatrace NGINX Agent into NGINX's config file {{ dynatrace_nginx_agent_linux_nginx_config_path }}"
  lineinfile:
    dest: "{{ dynatrace_nginx_agent_linux_nginx_config_path }}"
    regexp: 'export LD_PRELOAD="{{ dynatrace_nginx_agent_linux_agent_path }}"'
    line: 'export LD_PRELOAD="{{ dynatrace_nginx_agent_linux_agent_path }}"'
    insertafter: EOF
    state: "{{ dynatrace_nginx_agent_state }}"
    create: yes
    backup: yes
  sudo: yes

- name: "Inject the Dynatrace NGINX Agent into NGINX's config file {{ dynatrace_nginx_agent_linux_nginx_config_path }}"
  lineinfile:
    dest: "{{ dynatrace_nginx_agent_linux_nginx_config_path }}"
    regexp: 'export LD_PRELOAD="{{ dynatrace_nginx_agent_linux_agent_path }}"'
    line: 'export LD_PRELOAD="{{ dynatrace_nginx_agent_linux_agent_path }}"'
    insertafter: EOF
    state: "{{ dynatrace_nginx_agent_state }}"
    create: yes
    backup: yes
  become: yes

Use 'become' instead of 'sudo'.
Use 'become' instead of 'sudo'.
