From d1b5fa1c9881cd802e7b63aec8dd01d442c0034b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20J=C4=99drzejczyk?= Date: Mon, 4 Mar 2024 21:57:47 +0100 Subject: [PATCH] Add the option for assigning a specific SSH key to a node. (#1356) * Add the option for specifying an SSH key. * Add ability to specify SSH key. * Update config.sample.yaml * Update config.sample.yaml * Update bootstrap/templates/ansible/inventory/hosts.yaml.j2 * Update bootstrap/templates/ansible/inventory/hosts.yaml.j2 --------- Co-authored-by: Devin Buhl --- bootstrap/templates/ansible/inventory/hosts.yaml.j2 | 6 ++++++ config.sample.yaml | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bootstrap/templates/ansible/inventory/hosts.yaml.j2 b/bootstrap/templates/ansible/inventory/hosts.yaml.j2 index 8960a23d..4df83a28 100644 --- a/bootstrap/templates/ansible/inventory/hosts.yaml.j2 +++ b/bootstrap/templates/ansible/inventory/hosts.yaml.j2 @@ -8,6 +8,9 @@ kubernetes: "#{ item.name }#": ansible_user: "#{ item.ssh_user }#" ansible_host: "#{ item.address }#" + #% if item.ssh_key %# + ansible_ssh_private_key_file: "#{ item.ssh_key }#" + #% endif %# #% endif %# #% endfor %# #% if bootstrap_node_inventory | selectattr('controller', 'equalto', False) | list | length %# @@ -18,6 +21,9 @@ kubernetes: "#{ item.name }#": ansible_user: "#{ item.ssh_user }#" ansible_host: "#{ item.address }#" + #% if item.ssh_key %# + ansible_ssh_private_key_file: "#{ item.ssh_key }#" + #% endif %# #% endif %# #% endfor %# #% endif %# diff --git a/config.sample.yaml b/config.sample.yaml index ec3b4c7d..f080ad7b 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -46,11 +46,12 @@ bootstrap_node_default_gateway: "" # (Required) Use only 1, 3 or more ODD number of controller nodes, recommended is 3 # Worker nodes are optional bootstrap_node_inventory: [] - # - name: "" # Name of the node (must match [a-z0-9-\.]+) - # address: "" # IP address of the node - # controller: true # (Required) Set to true if this is a controller node - # ssh_user: "" # (Required: k3s) SSH username of the node - # talos_disk: "" # (Required: Talos) Device path or serial number of the disk for this node + # - name: "" # (Required) Name of the node (must match [a-z0-9-\.]+) + # address: "" # (Required) IP address of the node + # controller: true # (Required) Set to true if this is a controller node + # ssh_user: "" # (Required: k3s) SSH username of the node + # talos_disk: "" # (Required: Talos) Device path or serial number of the disk for this node + # ssh_key: "" # (Optional: k3s) Set specific SSH key for this node # ... # (Optional) The DNS server to use for the cluster, this can be an existing