From 8bbaea8fd96b07e023f792e9852e8f3ad2adb15b Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 11 Apr 2025 02:43:22 -0700 Subject: [PATCH] Simple admin user setup on a clean buntu machine --- ansible/inventory.yaml | 3 +++ ansible/local-setup-admin-user.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ansible/inventory.yaml create mode 100644 ansible/local-setup-admin-user.yaml diff --git a/ansible/inventory.yaml b/ansible/inventory.yaml new file mode 100644 index 0000000..7fc793a --- /dev/null +++ b/ansible/inventory.yaml @@ -0,0 +1,3 @@ +nigel: + hosts: + nigel.local: \ No newline at end of file diff --git a/ansible/local-setup-admin-user.yaml b/ansible/local-setup-admin-user.yaml new file mode 100644 index 0000000..2a0e4c6 --- /dev/null +++ b/ansible/local-setup-admin-user.yaml @@ -0,0 +1,27 @@ +# This playbook is meant to be a oneshot to be ran manually on the dev box +# The rest of the role stuff is meant to be ran as the admin user that +# this playbook creates for us +--- +- hosts: nigel.local + remote_user: nigel + vars: + admin: + username: nigel + tasks: + - name: Copy the nigel admin key + ansible.builtin.authorized_key: + user: "{{ admin.username }}" + state: present + key: "{{ lookup('file', '~/.ssh/nigel/admin.pub') }}" + - name: Prevent password based logins + become: true + ansible.builtin.lineinfile: + dest: /etc/ssh/sshd_config + line: PasswordAuthentication no + state: present + backup: true + - name: Restart SSH Daemon + become: true + ansible.builtin.service: + name: ssh + state: restarted \ No newline at end of file