Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ retry_files_enabled = False
interpreter_python = auto_silent
# Facts only under ansible_facts, never as top-level variables.
inject_facts_as_vars = False
# The VMs are recloned from images and get new host keys each time.
host_key_checking = False
# SSH checks each host key. The hub's key is recorded at the first connection
# (group_vars/hub.yml) and refused if it changes later. The VMs get new host
# keys at each reclone, so their connections turn the check off for the VM only
# (vm_inventory, lab_vm, client's ssh_config); the jump to the hub still checks.
host_key_checking = True

[ssh_connection]
pipelining = True
6 changes: 6 additions & 0 deletions ansible/group_vars/hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# The hub's SSH host key is recorded in ~/.ssh/known_hosts at the first
# connection, and a different key is refused later. To accept a key that changed
# on purpose, such as after a reinstall of the hub:
# ssh-keygen -R <hub address> && ssh <hub address> true
ansible_ssh_common_args: -o StrictHostKeyChecking=accept-new
25 changes: 25 additions & 0 deletions ansible/playbooks/lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,31 @@
roles:
- vm_inventory

# The base images ship the VM's user with the password "admin". The lab logs
# in with its key and runs sudo with no password, so each run turns the
# password off on each running VM, a new clone too: "*" matches no password,
# and, unlike a lock ("!"), it leaves key login when sshd runs without PAM. To
# get into a VM that SSH cannot reach, use the tart guest agent on the hub:
# tart exec lab-<vm> <command>
- name: VM accounts
hosts: vms
gather_facts: false
become: true
tags: [vms]
tasks:
- name: Turn off the password of the VM's user
when: lab_mode != 'stop'
ansible.builtin.shell: |
set -euo pipefail
if [ "$(getent shadow {{ lab_vm_user | quote }} | cut -d: -f2)" != '*' ]; then
usermod -p '*' {{ lab_vm_user | quote }}
echo changed
fi
args:
executable: /bin/bash
register: lab_vm_password
changed_when: "'changed' in lab_vm_password.stdout"

- name: Read the agents before a restart
hosts: hub
gather_facts: true
Expand Down
3 changes: 2 additions & 1 deletion ansible/roles/client/templates/ssh_config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Host {{ vm }}
User {{ lab_vm_user }}
IdentityFile {{ lab_ssh_key }}
ProxyJump {{ (hub.ansible_user ~ '@') if hub.ansible_user is defined else '' }}{{ hub.ansible_host }}
# Recloned VMs get new host keys.
# Recloned VMs get new host keys, so the check is off for the VM only. The
# jump to the hub reads ~/.ssh/known_hosts and checks the hub's key.
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
Expand Down
10 changes: 10 additions & 0 deletions ansible/roles/jaeger/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@
executable: /bin/bash
changed_when: true

# The UI has no authentication, so it listens only on the hub's tailnet
# address. The receiver of the traces stays on each interface, because the VMs
# reach it on the vmnet bridge.
- name: Read the hub's tailnet address
ansible.builtin.command: "{{ lab_tailscale_cli }} ip -4"
register: jaeger_tailnet_ip
changed_when: false
check_mode: false

- name: Write the trace collector config
ansible.builtin.template:
src: jaeger.yaml.j2
dest: "{{ lab_hub_state_abs }}/config/jaeger.yaml"
mode: "0600"
vars:
hub_state: "{{ lab_hub_state_abs }}"
jaeger_ui_addr: "{{ jaeger_tailnet_ip.stdout_lines | first | trim }}"

- name: Let the VMs reach the trace collector through the firewall
ansible.builtin.include_role:
Expand Down
9 changes: 5 additions & 4 deletions ansible/roles/jaeger/templates/jaeger.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Jaeger for the lab, in memory. OTLP gRPC on every interface, so that the VMs
# and remote agents can send traces. The UI on every interface too, so that a
# machine on the tailnet can open it; it has no authentication. Both serve the
# hub's Tailscale certificate, as the controller's API does.
# and remote agents can send traces. The UI only on the hub's tailnet address,
# because it has no authentication: a machine on the tailnet can open it, and a
# machine on the hub's local network cannot. Both serve the hub's Tailscale
# certificate, as the controller's API does.
service:
extensions: [jaeger_storage, jaeger_query]
pipelines:
Expand All @@ -15,7 +16,7 @@ extensions:
storage:
traces: memstore
http:
endpoint: 0.0.0.0:{{ lab_tracing_ui_port }}
endpoint: {{ jaeger_ui_addr }}:{{ lab_tracing_ui_port }}
tls:
cert_file: {{ hub_state }}/tls/api.crt
key_file: {{ hub_state }}/tls/api.key
Expand Down
4 changes: 3 additions & 1 deletion ansible/roles/lab_vm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
tart_vm_groups: "{{ ['vms'] + (['vms_in_place'] if (lab_vm_in_place | bool) else []) }}"
tart_vm_user: "{{ lab_vm_user }}"
tart_vm_ssh_key: "{{ lab_ssh_key }}"
# The VMs are on the hub's vmnet subnet, reachable only through the hub.
# The VMs are on the hub's vmnet subnet, reachable only through the hub. A
# recloned VM has a new host key, so the check is off for the VM only; the
# jump to the hub uses ~/.ssh/known_hosts and checks the hub's key.
tart_vm_ssh_args: >-
-o ProxyJump={{ (ansible_user ~ '@') if ansible_user is defined else '' }}{{ ansible_host }}
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/vm_inventory/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
ansible_host: "{{ item.stdout }}"
ansible_user: "{{ lab_vm_user }}"
ansible_ssh_private_key_file: "{{ lab_ssh_key }}"
# A recloned VM has a new host key, so the check is off for the VM only.
# The jump to the hub uses ~/.ssh/known_hosts and checks the hub's key.
ansible_ssh_common_args: >-
-o ProxyJump={{ (ansible_user ~ '@') if ansible_user is defined else '' }}{{ ansible_host }}
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5
Expand Down