Feat: add public key to ssh to user

This commit is contained in:
2022-01-11 22:20:52 +01:00
parent eadfdd97ce
commit c61e3a7826
4 changed files with 25 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
---
# tasks file for user
# Create user
- name: users -- Ensure wheel group exists
group:
name: wheel
@@ -16,6 +17,16 @@
state: present
system: "{{ user.system | default('no') }}"
#
- name: ssh -- Add public key
authorized_key:
user: "{{ user.username }}"
key: "{{ lookup('file', item.keyfile) }}"
state: present
with_items: "{{ user.public_key }}"
when: user.public_key
# Dotfiles
- name: Install for arch
import_tasks: arch.yml
when: ansible_os_family == "Archlinux"
@@ -28,18 +39,15 @@
ansible.builtin.git:
repo: "{{ user.config.giturl }}"
dest: "/home/{{ user.username }}/.dotfiles"
become: yes
- name: user owns its dotfiles
ansible.builtin.file:
path: "/home/{{ user.username }}/.dotfiles"
owner: "{{ user.username }}"
become: yes
- name: stow configs
ansible.builtin.command:
cmd: stow {{ item }}
chdir: "/home/{{ user.username }}/.dotfiles"
with_items: "{{ user.config.stowing }}"
become: yes