ansible/roles/raspi/tasks/main.yaml

46 lines
1,020 B
YAML

---
- name: Check whether user pi exists
command: "grep ^pi: /etc/passwd"
changed_when: no
failed_when: pi_user_check.rc != 0 and pi_user_check.rc != 1
register: pi_user_check
- name: Disable default user
user:
name: pi
password: !
when: pi_user_check.stdout_lines|length > 0
- name: Enable sshd
systemd:
name: sshd
enabled: yes
state: started
- name: Rotate display
lineinfile:
path: /boot/config.txt
line: "display_rotate={{ raspi_rotate_display }} # Managed by Ansible"
regexp: "^#?display_rotate"
when: raspi_rotate_display is defined
notify: reboot
- name: Disable swap
block:
- name: Stop swap service
systemd:
name: dphys-swapfile
state: stopped
enabled: no
- name: Remove swap file
command: dphys-swapfile uninstall
args:
removes: /var/swap
- name: Enable IPv6 SLAAC
lineinfile:
path: /etc/dhcpcd.conf
line: "slaac hwaddr # Managed by Ansible"
regexp: "^#?slaac"
notify: reboot