From 4897cdadbdc5dc9bf51010ead305ba54daee4741 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 1 Sep 2026 10:18:30 +0500 Subject: [PATCH] feat (roles): copies a config with hosts rules in human admin ~/.ssh --- roles/human_admin_user/files/ssh_config | 15 +++++++++++++++ roles/human_admin_user/tasks/main.yaml | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 roles/human_admin_user/files/ssh_config diff --git a/roles/human_admin_user/files/ssh_config b/roles/human_admin_user/files/ssh_config new file mode 100644 index 0000000..3ae4992 --- /dev/null +++ b/roles/human_admin_user/files/ssh_config @@ -0,0 +1,15 @@ +# PUT NEW BLOCKS STRICTLY BEFORE ANY MATCH BLOCK + + +# Private keys are NOT distributed via Ansible +# They must to be copied manually ONLY to those hosts that need access to others + +# Most of the home major LAN hosts should be accessible with this key +Match 192.168.0.0/24 + User max + IdentityFile ~/.ssh/max_regular_key + +# This virtual network has the same hosts range +Match 10.9.2.0/24 + User max + IdentityFile ~/.ssh/max_regular_key diff --git a/roles/human_admin_user/tasks/main.yaml b/roles/human_admin_user/tasks/main.yaml index 3391a6f..1608b22 100644 --- a/roles/human_admin_user/tasks/main.yaml +++ b/roles/human_admin_user/tasks/main.yaml @@ -48,6 +48,15 @@ group: "{{ human_admin_user }}" mode: u=rw,g=r,o-rwx +- name: Configure ssh client, by pushing the config + remote_user: ansible + ansible.builtin.copy: + src: "{{ role_path }}/files/ssh_config" + dest: "/home/{{ human_admin_user }}/.ssh/config" + owner: "{{ human_admin_user }}" + group: "{{ human_admin_user }}" + mode: u=rw,g=r,o-rwx + # WARNING: we've finished with the initial setup, drop ansible key # Push regular user key