Append 2 lines in visudo /etc/sudoers

Append 2 lines in /etc/sudoers

Hi I have 2 lines starting with User_Alias

How do i make sure both lines get appended

at the moment only the last line is being appended using this playbook

tasks:

  • name: add someuser to end of line

lineinfile:

dest: /etc/sudoers

state: present

regexp: ‘^(User_Alias(.*)$)’

backrefs: yes

backup: yes

line: ‘\1, someuser’

Output:

User_Alias SAP_ADMIN =user1, user2, user3, (see its blank here)

User_Alias ORA_ADMIN = user1, user2 ,user3, someuser

Append 2 lines in /etc/sudoers

Hi I have 2 lines starting with User_Alias

How do i make sure both lines get appended

at the moment only the last line is being appended using this playbook

You don’t. You put that content in as a separate, template based file in /etc/sudoers.d/whateveryoulike.conf, with ownership set to root and permissions set to 440.