I have a raspberry pi with "Raspbian GNU/Linux 11 (bullseye)" which I set up via ansible scripts. Now, I want to enable the "console auto-login". I know I can do that with the raspi-config tool. However, I want to enable the auto login via ansible as well. Is there a way to enable the console auto-login without user interaction via commandline?
Asked
Active
Viewed 2,260 times
1
-
1https://raspberrypi.stackexchange.com/questions/28907/how-could-one-automate-the-raspbian-raspi-config-setup raspiconfig is just a script that you can replace with an ansible playbook. – Steve Robillard Jan 08 '22 at 15:19
-
Thanks @SteveRobillard. With that hint, I was able to solve the problem. – Thomas Jan 08 '22 at 15:45
1 Answers
3
As mentioned by @SteveRobillard, raspi-config can be used in noninteractive mode. The functionality is, however, not documented. The functions have to be checked in the source code https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config.
To enable console auto-login, one can use:
sudo raspi-config nonint do_boot_behaviour B2
To check the auto-login, use:
sudo raspi-config nonint get_autologin
This should print 0 if autologin is enabled.
So to enable console autologin via ansible, the following task can be used:
- name: enable console auto login
become: true
ansible.builtin.command: raspi-config nonint do_boot_behaviour B2
Thomas
- 171
- 7
-
What this command does is create the file /etc/systemd/system/getty@tty1.service.d/autologin.conf. The reverse command raspi-config nonint do_boot_behaviour B1 deletes it – Grumoll Jun 01 '23 at 14:55