Skip to content

Commit acd1712

Browse files
authored
Merge pull request #161 from bedroge/cvmfs_server_metadata
Add role for updating meta information of CVMFS servers and repositories
2 parents 8b2b7c6 + 9ed0f75 commit acd1712

File tree

6 files changed

+91
-1
lines changed

6 files changed

+91
-1
lines changed

inventory/group_vars/all.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
eessi_cvmfs_repos_enabled: true
66

77
# Email address for the project.
8-
eessi_email: eessi@list.rug.nl
8+
eessi_email: support@eessi.io
99

1010
#
1111
# Defaults for eessi-hpc.org repos.
@@ -87,6 +87,7 @@ eessi_cvmfs_repositories:
8787
- CVMFS_GARBAGE_COLLECTION=true
8888
client_options: []
8989
use_for_ci: false
90+
description: Repository containing pilot versions of the EESSI software stack.
9091
- repository: data.eessi-hpc.org
9192
stratum0: rug-nl.stratum0.cvmfs.eessi-infra.org
9293
owner: "{{ cvmfs_repo_owner | default('root') }}"
@@ -97,6 +98,7 @@ eessi_cvmfs_repositories:
9798
- CVMFS_GARBAGE_COLLECTION=true
9899
client_options: []
99100
use_for_ci: false
101+
description: "Data files used for applications available in the EESSI stack."
100102
- repository: ci.eessi-hpc.org
101103
stratum0: rug-nl.stratum0.cvmfs.eessi-infra.org
102104
owner: "{{ cvmfs_repo_owner | default('root') }}"
@@ -106,6 +108,15 @@ eessi_cvmfs_repositories:
106108
- CVMFS_GARBAGE_COLLECTION=true
107109
client_options: []
108110
use_for_ci: true
111+
description: "Small-sized repository used for CI purposes."
112+
113+
# Meta information for CVMFS Stratum servers
114+
cvmfs_server_meta_administrator: "EESSI CVMFS Administrators"
115+
cvmfs_server_meta_email: "{{ eessi_email }}"
116+
cvmfs_server_meta_organisation: "EESSI"
117+
cvmfs_server_meta_custom:
118+
_comment: "See https://eessi.io/docs/ for more information about the EESSI repository."
119+
cvmfs_server_meta_website: "https://eessi.io"
109120

110121
# Override all the Galaxy defaults by our EESSI defaults.
111122
# This is required, beucase the galaxy_* variables are used inside the Ansible tasks.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
cvmfs_server_meta:
3+
administrator: "{{ cvmfs_server_meta_administrator | default('Your Name') }}"
4+
email: "{{ cvmfs_server_meta_email | default('you@organisation.org') }}"
5+
organisation: "{{ cvmfs_server_meta_organisation | default('Your Organisation') }}"
6+
custom: "{{ cvmfs_server_meta_custom | default({'_comment': 'Put arbitrary structured data here'}) }}"
7+
8+
cvmfs_repo_meta:
9+
administrator: "{{ cvmfs_server_meta_administrator | default('Your Name') }}"
10+
email: "{{ cvmfs_server_meta_email | default('you@organisation.org') }}"
11+
organisation: "{{ cvmfs_server_meta_organisation | default('Your Organisation') }}"
12+
description: "Repository content"
13+
url: "{{ cvmfs_server_meta_website | default('Project website') }}"
14+
recommended-stratum0: "stratum 0 url"
15+
recommended-stratum1s: ["stratum1 url", "stratum1 url"]
16+
17+
custom: "{{ cvmfs_server_meta_custom | default({'_comment': 'Put arbitrary structured data here'}) }}"
18+
...
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- name: Create a meta.json containing the CVMFS Server Meta Information
3+
ansible.builtin.copy:
4+
content: "{{ cvmfs_server_meta | to_nice_json(indent=2, sort_keys=false) }}"
5+
dest: "{{ cvmfs_srv_mount }}/cvmfs/info/v1/meta.json"
6+
owner: root
7+
group: root
8+
mode: 0644
9+
become: true
10+
11+
- name: Create meta information for each CVMFS repository
12+
ansible.builtin.include_tasks: repo_meta_info.yml
13+
vars:
14+
this_cvmfs_repo: "{{ item }}"
15+
this_cvmfs_repo_meta:
16+
description: "{{ item.description | default(omit) }}"
17+
recommended-stratum0: "http://{{ item.stratum0 }}/cvmfs/{{ item.repository }}"
18+
recommended-stratum1s: "{{ eessi_cvmfs_server_urls | selectattr('domain', 'in', item.repository) |
19+
map(attribute='urls') | map('regex_replace', '@fqrn@', item.repository) }}"
20+
with_items: "{{ eessi_cvmfs_repositories }}"
21+
when: "'cvmfsstratum0servers' in group_names or cvmfs_role == 'stratum0'"
22+
...
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Create temporary file for storing json
3+
ansible.builtin.tempfile:
4+
state: file
5+
suffix: .json
6+
register: tmp_json_file
7+
8+
- name: Add meta information for repository to temporary json file
9+
ansible.builtin.copy:
10+
content: "{{ cvmfs_repo_meta | combine(this_cvmfs_repo_meta) | to_nice_json(indent=2, sort_keys=false) }}"
11+
dest: "{{ tmp_json_file.path }}"
12+
mode: 0644
13+
14+
- name: Calculate the checksum of the json file
15+
ansible.builtin.stat:
16+
path: "{{ tmp_json_file.path }}"
17+
register: json_file_stat
18+
19+
- name: Get the current meta information of this repository from the server
20+
ansible.builtin.command:
21+
cmd: "cvmfs_swissknife info -M -r {{ this_cvmfs_repo_meta['recommended-stratum0'] }}"
22+
changed_when: false
23+
register: current_repo_meta
24+
25+
- name: Update the repository's meta information
26+
ansible.builtin.command:
27+
cmd: "cvmfs_server update-repoinfo -f {{ tmp_json_file.path }} {{ this_cvmfs_repo.repository }}"
28+
when: (current_repo_meta.stdout | checksum) != json_file_stat.stat.checksum
29+
become_user: "{{ cvmfs_repo_owner }}"
30+
31+
- name: Remove temporary json file
32+
ansible.builtin.file:
33+
path: "{{ tmp_json_file.path }}"
34+
state: absent
35+
...

stratum0.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
- role: geerlingguy.repo-epel
1717
when: ansible_facts['os_family'] == 'RedHat'
1818
- galaxyproject.cvmfs
19+
- cvmfs_server_meta_info
20+
...

stratum1.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
- role: geerlingguy.repo-epel
1818
when: ansible_facts['os_family'] == 'RedHat'
1919
- galaxyproject.cvmfs
20+
- cvmfs_server_meta_info
21+
...

0 commit comments

Comments
 (0)