From a921224e5660af9281092abdc5852e0441a7112d Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Wed, 22 Nov 2023 16:40:26 +0100 Subject: [PATCH] Add playbook for the initial basic deployment of a Hetzner VM This playbook does the following: - Creates a cit user (which has root privileges) using the cit_user role. - Sets the cit users ssh authorized_keys to the authorized_keys of the root user. --- playbooks/init_hetzer_vm.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 playbooks/init_hetzer_vm.yaml diff --git a/playbooks/init_hetzer_vm.yaml b/playbooks/init_hetzer_vm.yaml new file mode 100644 index 0000000..b2bcbb9 --- /dev/null +++ b/playbooks/init_hetzer_vm.yaml @@ -0,0 +1,25 @@ +--- +- name: Ensure cit user + hosts: all + roles: + - cit_user + +- name: Set the authorized_keys of the cit user to the authorized_keys of the root user + hosts: all + tasks: + - name: Ensure cit user .ssh directory + ansible.builtin.file: + path: /home/cit/.ssh + state: directory + owner: cit + group: cit + mode: "0700" + + - name: Copy the root users authorized_keys for the cit user + ansible.builtin.copy: + src: /root/.ssh/authorized_keys + remote_src: true + dest: /home/cit/.ssh/authorized_keys + owner: cit + group: cit + mode: "0600"