Solved - Replace three strings in one line

I have successfully used key/value pairs in a loop to do something similar…like this:

- name: SSO - Modify FILENAME
  become: true
  ansible.builtin.replace:
    path: "/tmp/FILENAME"
    regexp: "{{ item.key }}"
    replace: "{{ item.value }}"
  loop:
    - key: "ORIG_VALUE"
      value: "REPLACE_WITH"
    - key: "2ND_ORIG_VALUE"
      value: "2nd_REPLACE_WITH"

Of course this works for me knowing exactly what I need to replace - but with replace you can use wildcards I believe, so you might still be able to use the idea…

1 Like