-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ssh config and key capability to showroom (#7286)
- Loading branch information
Showing
5 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,13 @@ showroom_user_content_dir: "{{ showroom_user_home_dir }}/content" | |
# Some labs and demos require only root user access | ||
# ssh setup | ||
|
||
showroom_ssh_method: password # password | sshkey | ||
showroom_ssh_method: password # password | config (ie via config && ssh key) | ||
showroom_ssh_key_type: ed25519 # ed25519 | rsa | ||
|
||
showroom_enable_root_ssh: false | ||
# showroom_default_ssh_user: | ||
showroom_lab_users: | ||
- "{{ showroom_default_ssh_user | default('student') }}" | ||
|
||
showroom_container_compose_template: compose_default_template.j2 | ||
|
||
|
@@ -55,10 +59,3 @@ showroom_pip_packages: | |
showroom_work_dirs: | ||
- "{{ showroom_user_home_dir }}/content" # The showroom repo itself, asciidoc source e.g. Antora | ||
- "{{ showroom_user_home_dir }}/orchestration" # compose, kube files etc | ||
|
||
# TODO: Legacy vars from running antora via node. | ||
# Remove once validated no longer used: | ||
|
||
# showroom_npm_packages: | ||
# - antora | ||
# - "@antora/[email protected]" |
38 changes: 38 additions & 0 deletions
38
ansible/roles/showroom/tasks/22-showroom-users-security.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
|
||
- name: Implement internal sshkeys and configs for showroom access | ||
when: showroom_ssh_method == "sshkey" | ||
block: | ||
|
||
- name: Setup showroom user .ssh directory | ||
ansible.builtin.file: | ||
path: "{{ showroom_user_home_dir }}/.ssh" | ||
state: directory | ||
owner: "{{ showroom_user | default('showroom') }}" | ||
group: "{{ showroom_user_group | default('showroom') }}" | ||
mode: u=rwx,g-rwx,o-rwx | ||
|
||
- name: Generate an ed25519 OpenSSH keypair for showroom | ||
community.crypto.openssh_keypair: | ||
path: "{{ showroom_user_home_dir }}/.ssh/id_ed25519" | ||
type: ed25519 | ||
comment: "{{ showroom_user }}@localhost.com" | ||
become_user: "{{ showroom_user }}" | ||
register: r_ssh_key | ||
|
||
- name: Inject sshkey into the showroom_lab_users authorized_keys | ||
ansible.posix.authorized_key: | ||
user: "{{ __showroom_lab_user }}" | ||
state: present | ||
key: "{{ r_ssh_key.public_key }}" | ||
loop: "{{ showroom_lab_users }}" | ||
loop_control: | ||
loop_var: __showroom_lab_user | ||
|
||
- name: Generate SSH config file for the showroom user | ||
ansible.builtin.template: | ||
src: ssh_config.j2 | ||
dest: "{{ showroom_user_home_dir }}/.ssh/config" | ||
owner: "{{ showroom_user }}" | ||
group: "{{ showroom_user_group }}" | ||
mode: u=rw,g-rwx,o-rwx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% for user in showroom_lab_users %} | ||
# Entry for connecting as {{ user }} | ||
Host {{ user }} | ||
HostName {{ showroom_host | default('bastion') }} | ||
User {{ user }} | ||
IdentityFile {{ showroom_user_home_dir }}/.ssh/id_ed25519 | ||
Port 22 | ||
UserKnownHostsFile /dev/null | ||
StrictHostKeyChecking no | ||
|
||
{% endfor %} |