Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
delay: "{{ raspi_config_reboot_min_time }}"
timeout: "{{ raspi_config_reboot_max_wait_time }}"

- name: remove default user
when: "raspi_config_replace_user['name'] != raspi_config_auth_test_username"
user: name={{raspi_config_auth_test_username}} state=absent force=yes
async: 0
poll: 0
ignore_errors: True

- name: restart timezone dependent services
service:
name: "{{ item }}"
Expand Down
12 changes: 12 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
- import_tasks: setup_replace_user.yml
when: raspi_config_replace_user['name'] != None

- name: Verify if replace_user exists
stat:
path: "/etc/sudoers.d/{{ raspi_config_replace_user['name'] }}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small remark - shouldn't this also include the pseudo-priority prefix, in line with how the directory is organized by default?

register: raspi_config_replace_user_exists

- name: remove default user
when: "raspi_config_replace_user['name'] != None and raspi_config_replace_user_exists"
user: name={{raspi_config_auth_test_username}} state=absent force=yes
async: 0
poll: 0
ignore_errors: True

- import_tasks: security_check.yml

- name: ensure filesystem is resized
Expand Down
15 changes: 10 additions & 5 deletions tasks/setup_replace_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
- name: Create user {{ raspi_config_replace_user['name'] }}
user:
name: "{{ raspi_config_replace_user['name'] }}"
changed_when: True #to force handler call
notify:
- remove default user
group: "{{ raspi_config_replace_user['name'] }}"
groups: "sudo"
state: present

- name: Add your login key to {{ raspi_config_replace_user['name'] }}
authorized_key:
Expand All @@ -15,5 +15,10 @@
- name: Add {{ raspi_config_replace_user['name'] }} to sudoers
lineinfile:
args:
dest: /etc/sudoers
line: "{{ raspi_config_replace_user['name'] }} ALL=(ALL) NOPASSWD: ALL"
dest: "/etc/sudoers.d/{{ raspi_config_replace_user['name'] }}"
line: "{{ raspi_config_replace_user['name'] }} ALL=(ALL) NOPASSWD: ALL"
state: present
create: yes
owner: root
group: root
mode: 640