-Numerous changes to make more generic. Use varialbe for username. Defaults to "pi

-
This commit is contained in:
2022-05-08 14:40:16 +00:00
parent fc0b355f1d
commit d539e40943
36 changed files with 137 additions and 109 deletions

View File

@@ -1,29 +1,21 @@
---
- hosts: all
tasks:
- name: make sure user pi exists
become: true
ansible.builtin.user:
name: pi
groups: adm,cdrom,dip,plugdev,lxd,users,sudo
- name: make direcotry
become: true
file:
path: "/home/pi/.ssh"
owner: pi
group: pi
path: "/home/{{ def_username }}/.ssh"
owner: "{{ def_username }}"
group: "{{ def_username }}"
mode: '0700'
state: directory
- name: create empty file
become: true
file:
path: "/home/pi/.ssh/authorized_keys"
owner: pi
group: pi
path: "/home/{{ def_username }}/.ssh/authorized_keys"
owner: "{{ def_username }}"
group: "{{ def_username }}"
mode: '0644'
state: touch
- name: put pubkey
become: true
lineinfile:
path: "/home/pi/.ssh/authorized_keys"
path: "/home/{{ def_username }}/.ssh/authorized_keys"
line: "{{ pubkey }}"