From 0a3b5a9e2cb8a9bf217ed26feac502411903e92f Mon Sep 17 00:00:00 2001 From: Maksym Buz Date: Sun, 24 Aug 2025 13:27:53 +0200 Subject: [PATCH] Playbook will also install software-properties-common. Removed hardcoded host name. --- lxc_setup_ubuntu.yml | 10 ++++++++-- vars.yml | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lxc_setup_ubuntu.yml b/lxc_setup_ubuntu.yml index bd42fd5..6eecc34 100644 --- a/lxc_setup_ubuntu.yml +++ b/lxc_setup_ubuntu.yml @@ -1,6 +1,6 @@ --- - name: Secure and Configure a New LXC Container - hosts: ansible # Hosts or group defined in your inventory + hosts: '{{ hosts_to_work_on }}' # Hosts or group defined in your inventory become: yes # Run all tasks as root (sudo) tasks: - name: 1. Create user '{{ target_user }}' @@ -31,6 +31,12 @@ name: '{{ target_user }}' password_lock: yes + - name: 4.0. Install software-properties-common + ansible.builtin.apt: + name: software-properties-common + state: present + update_cache: yes + - name: 4.1. Disallow root login over SSH ansible.builtin.lineinfile: path: /etc/ssh/sshd_config @@ -54,4 +60,4 @@ listen: "restart sshd" ansible.builtin.service: name: sshd - state: restarted \ No newline at end of file + state: restarted diff --git a/vars.yml b/vars.yml index 0e49951..38107ed 100644 --- a/vars.yml +++ b/vars.yml @@ -3,4 +3,6 @@ target_user: 'mbuz' my_public_keys: - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINSGj0dxaA38QSBVY3DZiPb+qmIuTFxGo0mt4sbmYDa3 mbuz@macbook-pro" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOpvRkew+XpOAt7I/mizQbE/OJP1SO6NVl2/A1ZGzdU3 mbuz@windows-desktop" - - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIGWMJbHDCB8XCxPGth1229A3W/sPpvJHO9xBvegv4Sx mbuz@macbook-air" \ No newline at end of file + - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIGWMJbHDCB8XCxPGth1229A3W/sPpvJHO9xBvegv4Sx mbuz@macbook-air" + +hosts_to_work_on: ansible \ No newline at end of file