Skip to content

Commit 94de6b9

Browse files
fhennigclaude
andauthored
fix: check out correct Loculus commit to deploy pinned version (#214)
* deploy locally * Add helm role * feat(loculus): automate Loculus repo checkout and improve deployment - Add git checkout task to clone Loculus at specific commit SHA - Move from shell-based helm to kubernetes.core.helm module - Pin Loculus version in group_vars (loculus_commit_sha: 4948577ed) - Add loculus_repo_path and loculus_helm_chart_path to role defaults - Remove hardcoded helm_chart_path from host_vars - Enable proper Helm values file merging (base + custom) This makes Loculus deployment fully automated and version-controlled, following the pattern documented in LOCULUS_DEPLOYMENT_GUIDE.md. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * use root to checkout loculus * do not print the helm output, it's not useful * feat: add kubernetes.core collection to requirements Add kubernetes.core collection (>=2.3.0) to requirements.yml to support the kubernetes.core.helm module used in the Loculus deployment role. This fixes the CI linting error: Error loading plugin 'kubernetes.core.helm': No module named 'ansible_collections.kubernetes' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat(loculus): add Helm installation to deployment role Install Helm using gantsign.helm role before deploying Loculus. This ensures Helm is available for the kubernetes.core.helm module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix(ci): install Ansible collections and roles before syntax check Add steps to install collections and roles from requirements.yml before running syntax checks. This fixes the linting error: Error loading plugin 'kubernetes.core.helm': No module named 'ansible_collections.kubernetes' The CI was only installing ansible-core but not the required collections (kubernetes.core, community.general, etc.) or roles (gantsign.helm). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 122c827 commit 94de6b9

File tree

9 files changed

+71
-54
lines changed

9 files changed

+71
-54
lines changed

.github/workflows/ansible-quality.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ jobs:
1515

1616
- name: Install Ansible
1717
run: pip install ansible-core
18-
18+
19+
- name: Install Ansible collections
20+
run: ansible-galaxy collection install -r requirements.yml
21+
22+
- name: Install Ansible roles
23+
run: ansible-galaxy role install -r requirements.yml
24+
1925
- name: Setup CI environment
2026
run: |
2127
# Temporarily remove vault files to avoid decryption attempts

docs/configuration/reference.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ srsilo_viruses:
5757

5858
## Loculus Configuration
5959

60-
### Required Variables
61-
62-
Set in `host_vars/` or `group_vars/`:
63-
64-
| Variable | Description |
65-
|----------|-------------|
66-
| `kubectl_context` | kubectl context name |
67-
| `helm_chart_path` | Path to Loculus Helm chart |
68-
6960
### Application Settings
7061

7162
In `group_vars/loculus/main.yml`:

docs/deployment/loculus.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ Ansible role for deploying Loculus (pathogen sequence sharing platform) to Kuber
2020
| `loculus_cleanup_temp_files` | Clean up temp files after deployment (default: `true`) |
2121
| `loculus_kubeconfig_path` | Path to kubeconfig file |
2222

23-
**Required** (set in `host_vars/` or `group_vars/`):
24-
25-
| Variable | Description |
26-
|----------|-------------|
27-
| `kubectl_context` | kubectl context name |
28-
| `helm_chart_path` | Path to Loculus Helm chart |
29-
3023
**Configuration** (`group_vars/loculus/main.yml`):
3124

3225
- Application settings (name, host, organisms, URLs, etc.)

group_vars/loculus/main.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: 'W-ASAP'
22
host: 'db.wasap.genspectrum.org'
33

4+
# Pin the Loculus version
5+
loculus_commit_sha: 4948577ed8a054341e155b5c6f593996290a3320
6+
47
logo:
58
url: 'https://db.wasap.genspectrum.org/static/images/wasap-logo.png'
69
width: 200
@@ -111,10 +114,7 @@ organisms:
111114
args:
112115
- "--watch"
113116
- "--disableConsensusSequences"
114-
referenceGenomes:
115-
singleReference:
116-
nucleotideSequences: []
117-
genes: []
117+
referenceGenomes: []
118118
rsva:
119119
schema:
120120
organismName: 'RSV-A'
@@ -187,10 +187,7 @@ organisms:
187187
args:
188188
- "--watch"
189189
- "--disableConsensusSequences"
190-
referenceGenomes:
191-
singleReference:
192-
nucleotideSequences: []
193-
genes: []
190+
referenceGenomes: []
194191

195192
dataUseTerms:
196193
enabled: false

host_vars/localhost/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# Loculus Deployment Configuration
66
# ============================================================================
77
host: 'db.wasap.genspectrum.org'
8-
kubectl_context: 'k3d-loculusCluster'
9-
helm_chart_path: '/opt/loculus/loculus/kubernetes/loculus'
108
cleanup_temp_files: true
119

1210
# ============================================================================

requirements.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ collections:
1111
version: ">=8.0.0"
1212
- name: ansible.posix
1313
version: ">=1.5.0"
14+
- name: kubernetes.core
15+
version: ">=2.3.0"
16+
17+
roles:
18+
- src: gantsign.helm
19+
version: "2.13.0"

roles/loculus/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ loculus_cleanup_temp_files: true
1313
# Note: Run playbook without sudo (use --ask-become-pass instead)
1414
loculus_kubeconfig_path: "{{ lookup('env', 'HOME') }}/.kube/config"
1515

16+
# Loculus repository configuration
17+
loculus_repo_path: "/opt/loculus/loculus"
18+
loculus_commit_sha: "main" # Default, should be overridden in group_vars
19+
20+
# Derived path to Helm chart (subdirectory within the repo)
21+
loculus_helm_chart_path: "{{ loculus_repo_path }}/kubernetes/loculus"
22+
1623
# Static images to deploy
1724
# Add new virus images here as needed
1825
virus_images:

roles/loculus/tasks/main.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
---
2-
- name: Ensure temp directory exists
3-
file:
4-
path: "{{ loculus_temp_dir }}"
5-
state: directory
6-
mode: '0750'
7-
82
# TODO: Add nginx configuration automation for static file serving in future
93
# This should include adding location /static/ block to nginx config
104

@@ -37,29 +31,53 @@
3731
become: yes
3832
loop: "{{ static_images }}"
3933

34+
- name: Install Helm
35+
ansible.builtin.include_role:
36+
name: gantsign.helm
37+
38+
# Loculus deployment
39+
- name: Ensure temp directory exists
40+
file:
41+
path: "{{ loculus_temp_dir }}"
42+
state: directory
43+
mode: '0750'
44+
45+
- name: Ensure loculus repository parent directory exists
46+
file:
47+
path: "{{ loculus_repo_path | dirname }}"
48+
state: directory
49+
mode: '0755'
50+
51+
- name: Checkout Loculus Repository at specific commit
52+
ansible.builtin.git:
53+
repo: 'https://github.com/loculus-project/loculus.git'
54+
dest: "{{ loculus_repo_path }}"
55+
version: "{{ loculus_commit_sha }}"
56+
update: true
57+
force: true
58+
register: loculus_checkout
59+
become: yes
60+
61+
- name: Display checked out commit
62+
debug:
63+
msg: "Loculus checked out at commit {{ loculus_commit_sha }}"
64+
4065
- name: Generate values file from template
4166
template:
4267
src: values.yaml.j2
4368
dest: "{{ loculus_temp_dir }}/values.yaml"
4469
mode: '0640'
4570

46-
- name: Verify kubectl context is available
47-
shell: kubectl config get-contexts {{ kubectl_context }}
48-
register: kubectl_context_check
49-
environment:
50-
KUBECONFIG: "{{ loculus_kubeconfig_path }}"
51-
52-
- name: Apply Helm chart with values to loculus cluster
53-
shell: |
54-
kubectl config use-context {{ kubectl_context }}
55-
helm upgrade --install my-loculus {{ helm_chart_path }} -f {{ loculus_temp_dir }}/values.yaml
56-
register: helm_output
57-
environment:
58-
KUBECONFIG: "{{ loculus_kubeconfig_path }}"
59-
60-
- name: Display Helm output
61-
debug:
62-
var: helm_output.stdout_lines
71+
- name: Deploy Loculus via Helm
72+
kubernetes.core.helm:
73+
release_name: my-loculus
74+
release_namespace: loculus
75+
create_namespace: true
76+
chart_ref: "{{ loculus_helm_chart_path }}"
77+
values_files:
78+
- "{{ loculus_helm_chart_path }}/values.yaml"
79+
- "{{ loculus_temp_dir }}/values.yaml"
80+
kubeconfig: "{{ loculus_kubeconfig_path }}"
6381

6482
- name: Clean up temporary files
6583
file:

roles/loculus/templates/values.yaml.j2

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: '{{ name }}'
22
host: '{{ host }}'
3+
{% if loculus_commit_sha is defined %}
4+
sha: '{{ loculus_commit_sha[:7] }}'
5+
{% endif %}
36
environment: '{{ loculus_environment }}' # Do not change this: this setup uses a "local" environment as the public traffic is proxied through nginx.
47

58
runDevelopmentMainDatabase: {{ runDevelopmentMainDatabase | lower }}
@@ -138,13 +141,11 @@ organisms:
138141
{% endfor %}
139142
{% endfor %}
140143
referenceGenomes:
141-
singleReference:
142-
nucleotideSequences: {{ organism_config.referenceGenomes.singleReference.nucleotideSequences }}
143-
genes: {{ organism_config.referenceGenomes.singleReference.genes }}
144+
{{ organism_config.referenceGenomes }}
144145
{% endfor %}
145146

146147
dataUseTerms:
147148
enabled: {{ dataUseTerms.enabled | lower }}
148149
disableIngest: {{ disableIngest | lower }}
149150
disableEnaSubmission: {{ disableEnaSubmission | lower }}
150-
accessionPrefix: "{{ accessionPrefix }}"
151+
accessionPrefix: "{{ accessionPrefix }}"

0 commit comments

Comments
 (0)