Skip to content

Commit e0bdcd7

Browse files
authored
Merge pull request #621 from stackhpc/update/timestamps
Update dnf repos using latest Pulp timestamps (plus tooling)
2 parents 8113fbe + 86aa8b4 commit e0bdcd7

File tree

7 files changed

+165
-74
lines changed

7 files changed

+165
-74
lines changed

ansible/ci/update_timestamps.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- hosts: localhost
2+
tasks:
3+
- name: Get latest timestamps from sources
4+
latest_timestamps:
5+
repos_dict: "{{ appliances_pulp_repos }}"
6+
content_url: "https://ark.stackhpc.com/pulp/content"
7+
register: _result
8+
9+
- name: Overwrite repo timestamps with latest
10+
ansible.builtin.copy:
11+
dest: "{{ appliances_repository_root }}/environments/common/inventory/group_vars/all/timestamps.yml"
12+
content: "{{ repo_template | to_nice_yaml(indent=2) }}"
13+
backup: true
14+
vars:
15+
repo_template:
16+
appliances_pulp_repos: "{{ _result.timestamps }}"

ansible/library/latest_timestamps.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
__metaclass__ = type
2+
3+
DOCUMENTATION = r'''
4+
---
5+
module: latest_timestamps
6+
short_description: Gets the latest set of snapshots from Pulp
7+
version_added: "1.0.0"
8+
description: Gets the latest set of snapshots from given source URLs and returns dictionary to replace 'appliances_repo_timestamps' with
9+
author:
10+
- William Tripp
11+
- Steve Brasier
12+
'''
13+
14+
EXAMPLES = r'''
15+
- name: Get latest timestamps
16+
latest_timestamps:
17+
repos_dict: "{{ appliances_repo_timestamp_sources }}"
18+
content_url: "https://ark.stackhpc.com/pulp/content"
19+
register: result
20+
'''
21+
22+
RETURN = r'''
23+
latest_dict:
24+
description: Dictionary with updated timestamps
25+
type: dict
26+
returned: always
27+
changed_timestamps:
28+
description: List of repos that have updated timestamps
29+
type: str[]
30+
returned: always
31+
'''
32+
33+
from ansible.module_utils.basic import AnsibleModule
34+
import requests
35+
from bs4 import BeautifulSoup
36+
37+
def run_module():
38+
module_args = dict(
39+
repos_dict=dict(type='dict', required=True),
40+
content_url=dict(type='str', required=True)
41+
)
42+
43+
result = dict(
44+
changed=False,
45+
original_message='',
46+
message=''
47+
)
48+
49+
module = AnsibleModule(
50+
argument_spec=module_args,
51+
supports_check_mode=True
52+
)
53+
54+
timestamps = dict(module.params['repos_dict'])
55+
for repo in timestamps:
56+
for version in timestamps[repo]:
57+
58+
html_txt = requests.get(
59+
url= module.params['content_url'] + '/' + timestamps[repo][version]['path']
60+
).text
61+
timestamp_link_list = BeautifulSoup(html_txt,features="html.parser").body.find('pre').find_all() # getting raw list of timestamps from html
62+
timestamp_link_list = map(lambda x: x.string,timestamp_link_list) # stripping xml tags
63+
latest_timestamp = list(timestamp_link_list)[-1][:-1] # last timestamp in list with trailing / removed
64+
timestamps[repo][version]['timestamp'] = latest_timestamp
65+
66+
result['timestamps'] = dict(sorted(timestamps.items()))
67+
68+
module.exit_json(**result)
69+
70+
71+
def main():
72+
run_module()
73+
74+
75+
if __name__ == '__main__':
76+
main()

environments/.stackhpc/ansible.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ inventory = ../common/inventory,inventory
1010
collections_path = ../../ansible/collections
1111
roles_path = ../../ansible/roles
1212
filter_plugins = ../../ansible/filter_plugins
13+
library = ../../ansible/library
1314

1415
[ssh_connection]
1516
ssh_args = -o ServerAliveInterval=10 -o ControlMaster=auto -o ControlPath=~/.ssh/%r@%h-%p -o ControlPersist=240s -o PreferredAuthentications=publickey -o UserKnownHostsFile=/dev/null
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"cluster_image": {
3-
"RL8": "openhpc-RL8-250331-1627-cccd6c9c",
4-
"RL9": "openhpc-RL9-250331-1627-cccd6c9c"
3+
"RL8": "openhpc-RL8-250401-1100-9a3cffdb",
4+
"RL9": "openhpc-RL9-250401-1100-9a3cffdb"
55
}
66
}

environments/common/inventory/group_vars/all/defaults.yml

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -98,75 +98,3 @@ appliances_extra_packages_default:
9898
appliances_extra_packages_other: []
9999

100100
appliances_extra_packages: "{{ appliances_extra_packages_default + appliances_extra_packages_other }}"
101-
102-
###################### ark repo timestamps ###################################################
103-
104-
appliances_pulp_repos:
105-
baseos:
106-
'9.4':
107-
timestamp: 20241115T011711
108-
path: rocky/9.4/BaseOS/x86_64/os
109-
'9.5':
110-
timestamp: 20241216T013503
111-
path: rocky/9.5/BaseOS/x86_64/os
112-
'8.10':
113-
timestamp: 20241217T123729
114-
path: rocky/8.10/BaseOS/x86_64/os
115-
appstream:
116-
'9.4':
117-
timestamp: 20241112T003151
118-
path: rocky/9.4/AppStream/x86_64/os
119-
'9.5':
120-
timestamp: 20241217T005008
121-
path: rocky/9.5/AppStream/x86_64/os
122-
'8.10':
123-
timestamp: 20241217T123729
124-
path: rocky/8.10/AppStream/x86_64/os
125-
crb:
126-
'9.4':
127-
timestamp: 20241115T003133
128-
path: rocky/9.4/CRB/x86_64/os
129-
'9.5':
130-
timestamp: 20241217T005008
131-
path: rocky/9.5/CRB/x86_64/os
132-
'8.10':
133-
timestamp: 20241217T123729
134-
path: rocky/8.10/PowerTools/x86_64/os
135-
extras:
136-
'9.4':
137-
timestamp: 20241118T002802
138-
path: rocky/9.4/extras/x86_64/os
139-
'9.5':
140-
timestamp: 20241218T004632
141-
path: rocky/9.5/extras/x86_64/os
142-
'8.10':
143-
timestamp: 20241217T123729
144-
path: rocky/8.10/extras/x86_64/os
145-
epel:
146-
'9':
147-
timestamp: 20241213T010218
148-
path: epel/9/Everything/x86_64
149-
'8':
150-
timestamp: 20241216T235733
151-
path: epel/8/Everything/x86_64
152-
openhpc_base:
153-
'8':
154-
path: OpenHPC/2/EL_8
155-
timestamp: 20241218T154614
156-
'9':
157-
path: OpenHPC/3/EL_9
158-
timestamp: 20241218T154614
159-
openhpc_updates:
160-
'8':
161-
path: OpenHPC/2/updates/EL_8
162-
timestamp: 20241218T154614
163-
'9':
164-
path: OpenHPC/3/updates/EL_9
165-
timestamp: 20241218T154614
166-
ceph:
167-
'8':
168-
timestamp: 20231104T015751
169-
path: centos/8-stream/storage/x86_64/ceph-quincy
170-
'9':
171-
timestamp: 20240923T233036
172-
path: centos/9-stream/storage/x86_64/ceph-reef
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
appliances_pulp_repos:
2+
appstream:
3+
'8.10':
4+
path: rocky/8.10/AppStream/x86_64/os
5+
timestamp: 20250328T030013
6+
'9.4':
7+
path: rocky/9.4/AppStream/x86_64/os
8+
timestamp: 20241112T003151
9+
'9.5':
10+
path: rocky/9.5/AppStream/x86_64/os
11+
timestamp: 20250328T031822
12+
baseos:
13+
'8.10':
14+
path: rocky/8.10/BaseOS/x86_64/os
15+
timestamp: 20250328T030013
16+
'9.4':
17+
path: rocky/9.4/BaseOS/x86_64/os
18+
timestamp: 20241115T011711
19+
'9.5':
20+
path: rocky/9.5/BaseOS/x86_64/os
21+
timestamp: 20250326T030636
22+
ceph:
23+
'8':
24+
path: centos/8-stream/storage/x86_64/ceph-quincy
25+
timestamp: 20231104T015751
26+
'9':
27+
path: centos/9-stream/storage/x86_64/ceph-reef
28+
timestamp: 20240923T233036
29+
crb:
30+
'8.10':
31+
path: rocky/8.10/PowerTools/x86_64/os
32+
timestamp: 20250328T030013
33+
'9.4':
34+
path: rocky/9.4/CRB/x86_64/os
35+
timestamp: 20241115T003133
36+
'9.5':
37+
path: rocky/9.5/CRB/x86_64/os
38+
timestamp: 20250325T031428
39+
epel:
40+
'8':
41+
path: epel/8/Everything/x86_64
42+
timestamp: 20250326T000103
43+
'9':
44+
path: epel/9/Everything/x86_64
45+
timestamp: 20250326T000103
46+
extras:
47+
'8.10':
48+
path: rocky/8.10/extras/x86_64/os
49+
timestamp: 20250327T030422
50+
'9.4':
51+
path: rocky/9.4/extras/x86_64/os
52+
timestamp: 20241118T002802
53+
'9.5':
54+
path: rocky/9.5/extras/x86_64/os
55+
timestamp: 20250328T031822
56+
openhpc_base:
57+
'8':
58+
path: OpenHPC/2/EL_8
59+
timestamp: 20241218T154614
60+
'9':
61+
path: OpenHPC/3/EL_9
62+
timestamp: 20241218T154614
63+
openhpc_updates:
64+
'8':
65+
path: OpenHPC/2/updates/EL_8
66+
timestamp: 20241218T154614
67+
'9':
68+
path: OpenHPC/3/updates/EL_9
69+
timestamp: 20241218T154614

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ selinux # this is a shim to avoid having to use --system-site-packages, you stil
1010
netaddr
1111
matplotlib
1212
pulp-cli==0.23.2
13+
beautifulsoup4==4.13.3

0 commit comments

Comments
 (0)