As per my question above: "Ansible, attempting to get specific regex pattern to work with lineinfile module"
Essentially, I'm trying to get it to work in a single play as opposed to 2 separate plays, and for this a regex is required. I've tried a few variations that would work with sed, but they don't appear to work here. Maybe I'm crazy. Example of what I am trying to do is below:
- name: Change file contents on CentOS and Redhat servers.
lineinfile:
dest: /etc/blah/randomfile
regexp: '^ThisValueHere|^#ThisValueHere'
line: 'ThisValueHere no'
when: (ansible_distribution == "CentOS") or (ansible_distribution == "RedHat")
(Yeah yeah, ignore bad yml syntax, it's just fine in the actual playbook)
Basically I want to match lines STARTING WITH: (ThisValueHere, OR, #ThisValueHere), and then replace either of those lines with the line: (ThisValueHere no)
However, I can't seem to get it to work properly, maybe I just really have to brush up on regex stuffs. In any case, if anyone has any suggestions that would be highly appreciated!
Additionally if there is a link that could be provided to the "keys" to successful ansible regex usage, that would be greatly helpful as well.