Re: [ansible-project] Need help in exploring how to use regular expression to find the correct file name in a play book

18 views
Skip to first unread message
Message has been deleted

Dick Davies

unread,
Apr 25, 2017, 1:06:00 PM4/25/17
to ansible list
Might be better to list the files you want to edit as vars on each of the hosts
in your inventory.

On 25 April 2017 at 14:35, vinod kumar <vinodkum...@gmail.com> wrote:
> Hi All,
>
> I am writing a play book to add below two lines to a service config file
> under /etc/xinetd.d/. The filename generally starts with oscssd*. As i have
> multiple servers, this file name is getting changed and playbook is not
> working as expected as the filename is getting change.
>
> Please let me know how can i incorporate the regular expression to find the
> correct file name. /etc/xinetd.d/oscssd* is not working with lineinfile
> module.
>
> cat 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/oscssd3001"
> insertbefore: '^}'
> line: ' log_on_success ='
> ignore_errors: yes
> - name: updating with log_on_failure value in xinetd oscssd3001
> configuration
> lineinfile:
> name: "/etc/xinetd.d/oscssd3001"
> insertbefore: '^}'
> line: ' log_on_failure ='
> ignore_errors: yes
> - name: updating with log_on_success value in xinetd oscssd5001
> configuration
> lineinfile:
> name: "/etc/xinetd.d/oscssd5001"
> insertbefore: '^}'
> line: ' log_on_success ='
> ignore_errors: yes
> - name: updating with log_on_failure value in xinetd oscssd5001
> configuration
> lineinfile:
> name: "/etc/xinetd.d/oscssd5001"
> insertbefore: '^}'
> line: ' log_on_failure ='
> ignore_errors: yes
> - name: Reload of xinetd services
> service:
> name: xinetd
> state: reloaded
>
>
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/96f43351-b409-46d1-9bea-b16d2abc58b5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Kai Stian Olstad

unread,
Apr 26, 2017, 2:50:26 AM4/26/17
to ansible...@googlegroups.com
On 25.04.2017 15:35, vinod kumar wrote:
> I am writing a play book to add below two lines to a service config
> file
> under /etc/xinetd.d/. The filename generally starts with oscssd*. As i
> have
> multiple servers, this file name is getting changed and playbook is not
> working as expected as the filename is getting change.
>
> Please let me know how can i incorporate the regular expression to find
> the
> correct file name. /etc/xinetd.d/oscssd* is not working with lineinfile
> module.

Use the find module to find the file(s) en register the output in a
variable and use the result to change the files.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages