Hi The 'lineinfile' module can only operate on single files. This means that you have to use two steps - first identify the files you want to change, and then use the result to do the changes.
So practically speaking first use the 'find' module, register the result, and then use them in 'with_items' in the 'lineinfile' module. Btw Based on the matching criteria you specified that pattern is a glob style shell pattern and not a regular expression. This matters for the 'find' module. Dick On Tue, 25 Apr 2017 at 18:13, <[email protected]> wrote: > Hi All, > > I am very new to Ansible. I am stuck at a regular expression syntax for > specifying a file name. I am actually updating a file under /etc/xinetd.d/ > with some log parameters. > > I am updating the below two lines to the file /etc/xinetd.d/oscssd3001. > The challenge i am facing is that the filename is getting changed on most > of the servers and the file is same with the reg-expression > /etc/xinetd.d/oscssd*. Therefore i am searching for a way to use this in > the playbook. > > i am trying to append below two lines to /etc/xinetd.d/oscssd* file in > all my servers. > log_on_success = > log_on_failure = > > > xinetd.yml > --- > - name: xined log reduction playbook > hosts: test-servers > become: True > become_method: sudo > tasks: > - name: updating with log_on_success value in xinetd oscssd3001 > configuration > lineinfile: > name: "/etc/xinetd.d/oscssd*" > insertbefore: '^}' > line: ' log_on_success =' > ignore_errors: yes > - name: updating with log_on_failure value in xinetd oscssd3001 > configuration > lineinfile: > name: "/etc/xinetd.d/oscssd*" > insertbefore: '^}' > line: ' log_on_failure =' > ignore_errors: yes > - name: Reload of xinetd services > service: > name: xinetd > state: reloaded > > > Any ideas on how to achieve this. > > Thanks in advance. > > Regards, > Vinod. > > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/269eb97a-e385-4ff4-b40c-bb8fe8772b0b%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/269eb97a-e385-4ff4-b40c-bb8fe8772b0b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Dick Visser Sr. System & Network Engineer GÉANT Want to join us? We're hiring: https://www.geant.org/jobs -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwP32_vSsY6HrOSjH%2Bqs7%3DNSXsE1iXsLsVGnud2AtEiSdg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
