From fc0b355f1da34505a608063b44b36436e58183d1 Mon Sep 17 00:00:00 2001 From: Michael Pellegrino Date: Fri, 6 May 2022 19:48:36 +0000 Subject: [PATCH] -update deploy_authorized_keys to make sure user "pi" exists --- deploy_authorized_keys.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deploy_authorized_keys.yml b/deploy_authorized_keys.yml index acc0f1c..6895ecf 100644 --- a/deploy_authorized_keys.yml +++ b/deploy_authorized_keys.yml @@ -1,15 +1,29 @@ --- - 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 + mode: '0700' state: directory - name: create empty file + become: true file: path: "/home/pi/.ssh/authorized_keys" + owner: pi + group: pi + mode: '0644' state: touch - name: put pubkey + become: true lineinfile: path: "/home/pi/.ssh/authorized_keys" line: "{{ pubkey }}"