Help: Can't Update ifcfg-eth0

Dear Experts,

Could you please let me know what’s missing in my code?

Requirement: Need to change Domain search order in my ifcfg-eth0 file across multiple servers.

Desired state is just to update the search order one time and don’t change if user executes same playbook multiple times, do let me know if you have any questions.

Code:

Update search order in eth0

Dear Experts,

[...]

Requirement: Need to change Domain search order in my ifcfg-eth0 file across multiple servers.

[...]

      with_items:
        - {dest: '/tmp/ifcfg-eth0', regexp: '^DOMAIN=amer.com ham.am.com am.mds.com mds.com hmin.am.com', line: 'DOMAIN=ham.am.com amer.com am.mds.com mds.com hmin.am.com'}

What does happen if you shortened regexp to '^DOMAIN='?

Wawrzek

Hi Wawrzek,

If the regexp is set to ‘^DOMAIN=’? then its syntax error and I cannot execute the playbook, if its set to ‘^DOMAIN=?’ then its adding appending a line at the end instead of replacing.

Remove the question mark, that was part of of the sentence.
So it just

'^DOMAIN='

Excellent!! that did the trick…Thank you very much!