Apologies if this was already answered. I haven’t found the answer so far…
I have this templated line in the /etc/fstab file:
NFS_SVM:/p_n_s_REQ_ID_oracle_HOSTNAME_data
Would it be possible to replace NFS_SVM, REQ_ID and HOSTNAME using a single task, considering that I can’t use a template file…? How?
As the /etc/fstab file is not standard across all servers, I’m considering that a template file would not fit as a solution.
Yes, although I did not mention, I’m assuming the replace module would be the option to go with.
But I could not think/find a way to have it do 3 replacements in a single call/task.
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…
True, that would work.
But the reason I was not yet considering using it is that I’d like to keep the existing fstab file structure. Unless I did something wrong, the last time I use it it added the new lines to the end of the file… (Although I may ending up not have a choice and use it.)
Let me share a couple of tips on using the forum to make it easier for people to help out. In this case for tagging @jrglynn2 post as the answer as that one solved your need. We have a feature for that instead of requiring a topic title edit;
Solutions
If you get to a point where you consider a post by someone helped you to solve the issue, please tick the check-box below their message:
This will mark the message as the solution and show it in the first post for easy access, as well as recognize the person that helped:
I’m doing that for you in this case but wanted to mention it for future posts!
For all other replies where someone helped (like @jiholland, which is a very good suggestion) clicking the is appreciated.
Yes, the ansible.posix.mount module will add a new line and not replace the line NFS_SVM:/p_n_s_REQ_ID_oracle_HOSTNAME_data in /etc/fstab, but it will ensure idempotency and that entries added to /etc/fstab gets the right structure.