In my opinion, lineinfile should rarely be used, except in special cases where it is the only option.
At the point in time, most linux distros support an /etc/sudoers.d directory, which can contain individual files for all added sudoers rules. Use the copy or template module to drop a file in that directory. Barring that, I'd recommend, templating out the whole /etc/sudoers file, instead of trying to manipulate individual lines within it. On Thu, Jun 20, 2019 at 2:38 PM David McPherson <[email protected]> wrote: > I commented out the regex line but got the same result. the line was > added to the end of the file. > > Dave > > On Thursday, June 20, 2019 at 12:37:44 PM UTC-6, David McPherson wrote: >> >> I am attempting to add a group to the sudoers file after the line >> %wheel ALL=(ALL) ALL >> example >> >> ## Allows people in group wheel to run all commands >> %wheel ALL=(ALL) ALL >> doman\\vm_admins ALL-(ALL) ALL >> >> - name: add vm_admins to sudoers >> lineinfile: >> path: /etc/sudoers >> regexp: "^%wheel" >> insertafter: "^%wheel" >> line: '{{realm_name.realm}}\\vm_admins ALL=(ALL) ALL' >> backup: yes >> >> The result is that ansible is replacing the line with the new line >> instead of adding it after. >> >> example >> ## Allows people in group wheel to run all commands >> doman\\vm_admins ALL-(ALL) ALL >> >> Any help would be appreciated. >> >> Thanks, >> >> Dave >> > -- > 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/68b7f7e6-3bb4-4bf8-b81a-0070ae7c7d96%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/68b7f7e6-3bb4-4bf8-b81a-0070ae7c7d96%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- 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/CAD8N0v_4mq3kBBNnsjbABN%3Di79eeJeMVDt9ss%2BzE1KhHbCSZZA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
