Thank you Jeff! I ended up using a shell script with sed. On Wednesday, June 15, 2022 at 1:37:01 PM UTC+2 Jeff S wrote:
> You can use those *modules, replace & lineinfile*, to search for a > pattern and replace it with something. > ansible.builtin.replace module – Replace all instances of a particular > string in a file using a back-referenced regular expression — Ansible > Documentation > <https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html> > ansible.builtin.lineinfile module – Manage lines in text files — Ansible > Documentation > <https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html> > or use the *shell module* to work with sed! > > On Tuesday, June 14, 2022 at 4:59:38 PM UTC+2 Laci wrote: > >> >> So far my best option is to run a command which invokes sed >> On Tuesday, June 14, 2022 at 2:30:01 PM UTC+2 Laci wrote: >> >>> I'm working on a playbook which would remove lines from a file >>> containing specific hostname. >>> I want to use Ansible to remove the hostname AND surrounding lines. Here >>> is an example of a block that I need to remove: >>> >>> FileSet { >>> Name = "vcenter-hostname05" >>> Include { >>> Options { >>> signature = SHA1 >>> compression=GZIP >>> noatime=yes >>> } >>> Plugin = "vsphere: server=vsphere-vcenter host=hostname05.domain.com >>> abort_on_error" >>> } >>> } >>> >>> Does anyone have a suggestion how would I match the lines when all I >>> have is *hostname05*? >>> >> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d3a2933c-0a29-45cb-99ea-031369b5a037n%40googlegroups.com.
