Skip to content

Commit

Permalink
role default_group: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dometto committed Sep 18, 2024
1 parent 588223b commit 7ea022f
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions playbooks/roles/default_group/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
- name: Ubuntu
when: ansible_distribution == 'Ubuntu'
block:
- name: Enable adding extra groups
ansible.builtin.lineinfile:
path: /etc/adduser.conf
line: 'ADD_EXTRA_GROUPS=1'
regexp: '^#?ADD_EXTRA_GROUPS='
- name: Enable adding extra groups
ansible.builtin.lineinfile:
path: /etc/adduser.conf
line: 'ADD_EXTRA_GROUPS=1'
regexp: '^#?ADD_EXTRA_GROUPS='

- name: Find EXTRA_GROUPS
register: extra_groups
command: 'grep "^EXTRA_GROUPS=" /etc/adduser.conf'
failed_when: "extra_groups.rc == 2"
changed_when: false
- name: Find EXTRA_GROUPS
register: extra_groups
command: 'grep "^EXTRA_GROUPS=" /etc/adduser.conf'
failed_when: "extra_groups.rc == 2"
changed_when: false

- name: Add extra groups instruction
ansible.builtin.lineinfile:
state: present
line: "EXTRA_GROUPS=\"\""
insertbefore: EOF
path: /etc/adduser.conf
when: not extra_groups.stdout
- name: Add extra groups instruction
ansible.builtin.lineinfile:
state: present
line: "EXTRA_GROUPS=\"\""
insertbefore: EOF
path: /etc/adduser.conf
when: not extra_groups.stdout

- name: Add new group to extra groups instruction
ansible.builtin.replace:
path: /etc/adduser.conf
replace: 'EXTRA_GROUPS="{{ default_group_group.groupname }} \1"'
regexp: '^(?!.*[\s\"]+{{ default_group_group.groupname }}[\s\"]+)EXTRA_GROUPS=\"(.*)\"'
- name: Add new group to extra groups instruction
ansible.builtin.replace:
path: /etc/adduser.conf
replace: 'EXTRA_GROUPS="{{ default_group_group.groupname }} \1"'
regexp: '^(?!.*[\s\"]+{{ default_group_group.groupname }}[\s\"]+)EXTRA_GROUPS=\"(.*)\"'

0 comments on commit 7ea022f

Please sign in to comment.