Skip to content

Commit eb89c99

Browse files
committed
Fix linting on merge of origin/main
1 parent 9a3b4da commit eb89c99

File tree

14 files changed

+362
-308
lines changed

14 files changed

+362
-308
lines changed

ansible/adhoc/deploy-pulp.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2+
23
- name: Install pulp on server
3-
become: yes
4+
become: true
45
hosts: pulp_server
56
tasks:
67
- name: Install pulp
@@ -9,10 +10,10 @@
910
tasks_from: install.yml
1011
public: true
1112

12-
- name: Print Pulp endpoint
13-
become: no
14-
debug:
15-
msg: |
16-
Server configured, override 'appliances_pulp_url' with
13+
- name: Print Pulp endpoint
14+
become: false
15+
ansible.builtin.debug:
16+
msg: |
17+
Server configured, override 'appliances_pulp_url' with
1718
appliances_pulp_url: "http://{{ hostvars[groups['pulp_server'] | first].ansible_host }}:{{ pulp_site_port }}"
18-
(or the correct IP if multi-homed) in your environments
19+
(or the correct IP if multi-homed) in your environments

ansible/filter_plugins/utils.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,28 @@ def to_ood_regex(items):
5656

5757
# There's a python bug which means re.sub() can't use '\d' in the replacement so
5858
# have to do replacement in two stages:
59-
r = [re.sub(r"\d+", 'XBACKSLASHX', v) for v in items]
60-
r = [v.replace('XBACKSLASHX', '\d+') for v in set(r)]
61-
r = ['(%s)' % v for v in r]
62-
return '|'.join(r)
59+
r = [re.sub(r"\d+", "XBACKSLASHX", v) for v in items]
60+
r = [v.replace("XBACKSLASHX", r"\d+") for v in set(r)]
61+
r = [f"({v})" for v in r]
62+
return "|".join(r)
6363

64+
65+
# pylint: disable=useless-object-inheritance
6466
class FilterModule(object):
65-
''' Ansible core jinja2 filters '''
67+
"""Ansible core jinja2 filters"""
6668

6769
# pylint: disable=missing-function-docstring
6870
def warn(self, message, **kwargs): # pylint: disable=unused-argument
6971
Display().warning(message)
7072
return message
7173

72-
def filters(self): # pylint: disable=missing-function-docstring
74+
# pylint: disable=missing-function-docstring
75+
def filters(self):
7376
return {
7477
# jinja2 overrides
75-
'readfile': readfile,
76-
'prometheus_node_exporter_targets': prometheus_node_exporter_targets,
77-
'exists': exists,
78-
'warn': self.warn,
79-
'to_ood_regex': to_ood_regex,
78+
"readfile": readfile,
79+
"prometheus_node_exporter_targets": prometheus_node_exporter_targets,
80+
"exists": exists,
81+
"warn": self.warn,
82+
"to_ood_regex": to_ood_regex,
8083
}

ansible/library/latest_timestamps.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,23 @@ def run_module(): # pylint: disable=missing-function-docstring
6363
for version in timestamps[repo]:
6464

6565
html_txt = requests.get(
66-
url= module.params['content_url'] + '/' + timestamps[repo][version]['pulp_path']
67-
).text
68-
timestamp_link_list = BeautifulSoup(html_txt,features="html.parser").body.find('pre').find_all() # getting raw list of timestamps from html
69-
timestamp_link_list = map(lambda x: x.string,timestamp_link_list) # stripping xml tags
70-
latest_timestamp = list(timestamp_link_list)[-1][:-1] # last timestamp in list with trailing / removed
71-
timestamps[repo][version]['pulp_timestamp'] = latest_timestamp
72-
result['timestamps'] = dict(sorted(timestamps.items()))
66+
url=module.params["content_url"]
67+
+ "/"
68+
+ timestamps[repo][version]["pulp_path"]
69+
).text
70+
timestamp_link_list = (
71+
BeautifulSoup(html_txt, features="html.parser")
72+
.body.find("pre")
73+
.find_all()
74+
) # getting raw list of timestamps from html
75+
timestamp_link_list = map(
76+
lambda x: x.string, timestamp_link_list
77+
) # stripping xml tags
78+
latest_timestamp = list(timestamp_link_list)[-1][
79+
:-1
80+
] # last timestamp in list with trailing / removed
81+
timestamps[repo][version]["pulp_timestamp"] = latest_timestamp
82+
result["timestamps"] = dict(sorted(timestamps.items()))
7383

7484
module.exit_json(**result)
7585

ansible/roles/dnf_repos/README.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
dnf_repos
2-
=========
1+
# dnf_repos
32

4-
Modifies repo definitions for repofiles in `/etc/yum.repos.d` to point to snapshots in StackHPC's Ark Pulp server or mirrors of them
3+
Modifies repository definitions for repofiles in `/etc/yum.repos.d` to point to snapshots in StackHPC's Ark Pulp server or mirrors of them
54
on a local Pulp server.
65

7-
Requirements
8-
------------
6+
## Requirements
97

108
Requires Ark credentials if using StackHPC's upstream Ark server.
119

12-
Role Variables
13-
--------------
10+
## Role Variables
1411

15-
Variables in this role are also required by `pulp_site` so set in
12+
Variables in this role are also required by `pulp_site` so set in
1613
`environments/common/inventory/groups_vars/all/dnf_repos.yml`. See that file for detailed default values.
1714

1815
- `dnf_repos_repos`: Dict of dicts containing information to construct URLs for Ark snapshots from the target Pulp server for each Rocky version. For example:
19-
```
20-
dnf_repos_repos:
21-
appstream: # ansible.builtin.yum_repository:name
22-
'8.10': # ansible_distribution_version or ansible_distribution_major_version
23-
repo_file: Rocky-AppStream # yum_repository: file
24-
# repo_name: # optional, override yum_repository:name
25-
pulp_path: rocky/8.10/AppStream/x86_64/os # The subpath of the the upstream Ark server's content endpoint URL for the repo's snapshots, see https://ark.stackhpc.com/pulp/content/
26-
pulp_timestamp: 20250614T013846
27-
# pulp_content_url: # optional, dnf_repos_pulp_content_url
28-
'9.6':
29-
...
30-
```
16+
```yaml
17+
dnf_repos_repos:
18+
appstream: # ansible.builtin.yum_repository:name
19+
"8.10": # ansible_distribution_version or ansible_distribution_major_version
20+
repo_file: Rocky-AppStream # yum_repository: file
21+
# repo_name: # optional, override yum_repository:name
22+
pulp_path: rocky/8.10/AppStream/x86_64/os # The subpath of the the upstream Ark server's content endpoint URL for the repo's snapshots, see https://ark.stackhpc.com/pulp/content/
23+
pulp_timestamp: 20250614T013846
24+
# pulp_content_url: # optional, dnf_repos_pulp_content_url
25+
"9.6": ...
26+
```
3127
- `dnf_repos_default`: Appliance default repos to use Ark snapshots for. Following same format as `dnf_repos_repos`.
32-
See for appliance default repo list `environments/common/inventory/group_vars/all/dnf_repo_timestamps.yml`.
28+
See for appliance default repository list `environments/common/inventory/group_vars/all/dnf_repo_timestamps.yml`.
3329
- `dnf_repos_extra`: Additional repos to use Ark snapshots for. Follows same format as
3430
`dnf_repos_repos`. Defaults to `{}`
35-
- `dnf_repos_pulp_content_url`: Optional str. Content URL of Pulp server to use Ark snapshots from.
31+
- `dnf_repos_pulp_content_url`: Optional str. Content URL of Pulp server to use Ark snapshots from.
3632
Defaults to `{{ appliances_pulp_url }}/pulp/content`
3733
- `dnf_repos_username`: Optional str. Username for Ark. Should be set if using upstream StackHPC Ark
3834
Pulp server, but omitted if using local Pulp server (see `ansible/roles/pulp_site`)

ansible/roles/hpctests/library/plot_nxnlatbw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def run_module(): # pylint: disable=missing-function-docstring, too-many-locals
178178
float(vals[3]),
179179
)
180180
except ValueError:
181-
print('warning: skipping line %i (%s) - parse failure' % (ln, line))
181+
print(f"warning: skipping line {ln} ({line}) - parse failure")
182182
continue
183183
latencies[rankA, rankB] = lat
184184
bandwidths[rankA, rankB] = bw
@@ -193,7 +193,7 @@ def run_module(): # pylint: disable=missing-function-docstring, too-many-locals
193193
module.fail_json(
194194
"Results contained %i ranks but %i node names provided" # pylint: disable=consider-using-f-string
195195
% (len(rankAs), len(nodes)),
196-
**result
196+
**result,
197197
)
198198

199199
# find min values:

ansible/roles/pulp_site/README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
pulp_site
2-
=========
1+
# pulp_site
32

4-
Contains playbooks to deploy a Pulp server and sync its content with repo snapshots in
3+
Contains playbooks to deploy a Pulp server and sync its content with repository snapshots in
54
StackHPC's Ark Pulp server
65

7-
Requirements
8-
------------
6+
## Requirements
97

108
Requires Ark credentials. The VM you are deploying Pulp on must allow ingress on `pulp_site_port`
119
and not be externally accessible (as the Pulp server's content is unauthenticated). Rocky Linux 9 has been
1210
tested as the target VM for deploying Pulp.
1311

14-
Role Variables
15-
--------------
12+
## Role Variables
1613

17-
- `pulp_site_url`: Required str. The base url from which Pulp content will be hosted. Defaults to `{{ appliances_pulp_url }}`.
18-
Value to set for ``appliances_pulp_url` will be generated and output by the deploy.yml playbook.
14+
- `pulp_site_url`: Required str. The base URL from which Pulp content will be hosted. Defaults to `{{ appliances_pulp_url }}`.
15+
Value to set for ``appliances_pulp_url` will be generated and output by the deploy.yml playbook.
1916
- `pulp_site_port`: Optional str. Port to serve Pulp server on. Defaults to `8080`.
2017
- `pulp_site_username`: Optional str. Admin username for the Pulp server. Defaults to `admin`.
2118
- `pulp_site_password`: Required str. Admin password for the Pulp server. Defaults to `{{ vault_pulp_admin_password }}`.
@@ -24,13 +21,13 @@ Role Variables
2421
- `pulp_site_upstream_content_url`: Optional str. Content URL of upstream Ark Pulp. Defaults to `https://ark.stackhpc.com/pulp/content`.
2522
- `pulp_site_install_dir`: Optional str. Directory on Pulp host to install config and persistent state to be mounted into Pulp container. Defaults to `/home/rocky/pulp`.
2623
- `pulp_site_target_facts`: Optional str. The `ansible_facts` of a host which will be pulling from your Pulp server, allowing the role to auto-discover the necessary repos to pull.
27-
defaults to `{{ hostvars[groups['pulp'][0]]['ansible_facts'] }}`.
24+
defaults to `{{ hostvars[groups['pulp'][0]]['ansible_facts'] }}`.
2825
- `pulp_site_target_distribution_version`: Optional str. The Rocky Linux minor release to sync repos from Ark for. Defaults to `{{ pulp_site_target_facts['distribution_version'] }}`.
29-
- `pulp_site_rpm_repo_defaults`: Optional dict. Contains key value pairs for fields which are common to all repo definition in `pulp_site_rpm_repos`. Includes values for `remote_username`,
30-
`remote_password` and `policy` by default.
31-
- `pulp_site_rpm_repos`: Optional list of dicts. List of repo definitions in format required by the `stackhpc.pulp.pulp_repository`. Defaults to modified versions of repos defined in
32-
`dnf_repos_all`.
33-
- `pulp_site_rpm_publications`: Optional list of dicts. List of repo definitions in format required by the `stackhpc.pulp.pulp_publication`. Defaults to list of publications for repos defined in
34-
`dnf_repos_all`.
35-
- `pulp_site_rpm_distributions`: Optional list of dicts. List of repo definitions in format required by the `stackhpc.pulp.pulp_distribution`. Defaults to list of distributions for repos defined in
36-
`dnf_repos_all`.
26+
- `pulp_site_rpm_repo_defaults`: Optional dict. Contains key-value pairs for fields which are common to all repository definition in `pulp_site_rpm_repos`. Includes values for `remote_username`,
27+
`remote_password` and `policy` by default.
28+
- `pulp_site_rpm_repos`: Optional list of dicts. List of repository definitions in format required by the `stackhpc.pulp.pulp_repository`. Defaults to modified versions of repos defined in
29+
`dnf_repos_all`.
30+
- `pulp_site_rpm_publications`: Optional list of dicts. List of repository definitions in format required by the `stackhpc.pulp.pulp_publication`. Defaults to list of publications for repos defined in
31+
`dnf_repos_all`.
32+
- `pulp_site_rpm_distributions`: Optional list of dicts. List of repository definitions in format required by the `stackhpc.pulp.pulp_distribution`. Defaults to list of distributions for repos defined in
33+
`dnf_repos_all`.

ansible/roles/pulp_site/filter_plugins/pulp-list-filters.py

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ class FilterModule(object):
44

55
def filters(self): # pylint: disable=missing-function-docstring
66
return {
7-
'to_rpm_repos': self.to_rpm_repos,
8-
'to_rpm_pubs': self.to_rpm_pubs,
9-
'to_rpm_distros': self.to_rpm_distros,
10-
'select_repos': self.select_repos,
7+
"to_rpm_repos": self.to_rpm_repos,
8+
"to_rpm_pubs": self.to_rpm_pubs,
9+
"to_rpm_distros": self.to_rpm_distros,
10+
"select_repos": self.select_repos,
1111
}
12-
12+
1313
def select_repos(self, dnf_repos, target_distro_ver):
14-
""" Filter dnf_repos to only those for a relevant distribution version (M.m or M). Returns a list of dicts.
15-
Also adds pulp_repo_name field to give the repository a unique name in Pulp to be referenced by subsequent
16-
filters
14+
"""Filter dnf_repos to only those for a relevant distribution version (M.m or M).
15+
Returns a list of dicts.
16+
Also adds pulp_repo_name field to give the repository a unique name in Pulp
17+
to be referenced by subsequent filters
1718
"""
18-
19-
target_distro_ver_major = target_distro_ver.split('.')[0]
19+
20+
target_distro_ver_major = target_distro_ver.split(".")[0]
2021

2122
rpm_repos = []
2223
for repokey in dnf_repos:
@@ -26,41 +27,54 @@ def select_repos(self, dnf_repos, target_distro_ver):
2627
elif target_distro_ver_major in dnf_repos[repokey]:
2728
selected_ver = target_distro_ver_major
2829
else:
29-
raise ValueError(f'No key matching {target_distro_ver_major} or {target_distro_ver} found in f{repokey}')
30+
raise ValueError(
31+
# pylint: disable-next=line-too-long
32+
f"No key matching {target_distro_ver_major} or {target_distro_ver} found in f{repokey}"
33+
)
3034
repo_data = dnf_repos[repokey][selected_ver]
31-
repo_data['pulp_repo_name'] = f"{repokey}-{selected_ver}-{dnf_repos[repokey][selected_ver]['pulp_timestamp']}"
35+
repo_data["pulp_repo_name"] = (
36+
f"{repokey}-{selected_ver}-{dnf_repos[repokey][selected_ver]['pulp_timestamp']}"
37+
)
3238
rpm_repos.append(repo_data)
3339
return rpm_repos
3440

3541
def to_rpm_repos(self, rpm_info, content_url, repo_defaults):
36-
""" Filter repo object list given by select_repos into dict required by the pulp_repository_rpm_repos variable
37-
from stackhpc.pulp.pulp_repository role
42+
"""Filter repo object list given by select_repos into dict required by the
43+
pulp_repository_rpm_repos variable from stackhpc.pulp.pulp_repository role
3844
"""
3945
rpm_repos = []
4046
for repo_data in rpm_info:
41-
rpm_data = repo_defaults.copy() # NB: this changes behaviour vs before, so now defaults can correctly be overriden
42-
rpm_data['name'] = repo_data['pulp_repo_name']
43-
rpm_data['url'] = '/'.join([content_url, repo_data['pulp_path'], repo_data['pulp_timestamp']])
44-
rpm_data['state'] = 'present'
47+
rpm_data = (
48+
repo_defaults.copy()
49+
) # NB: this changes behaviour vs before, so now defaults can correctly be overriden
50+
rpm_data["name"] = repo_data["pulp_repo_name"]
51+
rpm_data["url"] = "/".join(
52+
[content_url, repo_data["pulp_path"], repo_data["pulp_timestamp"]]
53+
)
54+
rpm_data["state"] = "present"
4555
rpm_repos.append(rpm_data)
4656
return rpm_repos
4757

48-
def to_rpm_pubs(self, list):
49-
""" Filter repo object list given by select_repos into dict required by the pulp_publication_rpm variable
50-
from stackhpc.pulp.pulp_publication role
58+
def to_rpm_pubs(self, _list):
59+
"""Filter repo object list given by select_repos into dict required by the
60+
pulp_publication_rpm variable from stackhpc.pulp.pulp_publication role
5161
"""
52-
pub_list = map(lambda x: {
53-
'repository': x['pulp_repo_name'],
54-
'state': 'present' }, list)
62+
pub_list = map(
63+
lambda x: {"repository": x["pulp_repo_name"], "state": "present"}, _list
64+
)
5565
return pub_list
56-
57-
def to_rpm_distros(self, list):
58-
""" Filter repo object list given by select_repos into dict required by the pulp_distirubtion_rpm variable
59-
from stackhpc.pulp.pulp_distribution role
66+
67+
def to_rpm_distros(self, _list):
68+
"""Filter repo object list given by select_repos into dict required by the
69+
pulp_distirubtion_rpm variable from stackhpc.pulp.pulp_distribution role
6070
"""
61-
distro_list = map(lambda x: {
62-
'name': x['pulp_repo_name'],
63-
'repository': x['pulp_repo_name'],
64-
'base_path': '/'.join([x['pulp_path'],x['pulp_timestamp']]),
65-
'state': 'present' }, list)
71+
distro_list = map(
72+
lambda x: {
73+
"name": x["pulp_repo_name"],
74+
"repository": x["pulp_repo_name"],
75+
"base_path": "/".join([x["pulp_path"], x["pulp_timestamp"]]),
76+
"state": "present",
77+
},
78+
_list,
79+
)
6680
return distro_list

ansible/roles/pulp_site/tasks/install.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,29 @@
2727
publish:
2828
- "{{ pulp_site_port }}:80"
2929
volume:
30-
- "{{ pulp_site_install_dir }}/settings:/etc/pulp{{ _pulp_site_selinux_suffix }}"
31-
- "{{ pulp_site_install_dir }}/pulp_storage:/var/lib/pulp{{ _pulp_site_selinux_suffix }}"
32-
- "{{ pulp_site_install_dir }}/pgsql:/var/lib/pgsql{{ _pulp_site_selinux_suffix }}"
33-
- "{{ pulp_site_install_dir }}/containers:/var/lib/containers{{ _pulp_site_selinux_suffix }}"
30+
- "{{ pulp_site_install_dir }}/settings:/etc/pulp{{ _pulp_site_selinux_suffix }}"
31+
- "{{ pulp_site_install_dir }}/pulp_storage:/var/lib/pulp{{ _pulp_site_selinux_suffix }}"
32+
- "{{ pulp_site_install_dir }}/pgsql:/var/lib/pgsql{{ _pulp_site_selinux_suffix }}"
33+
- "{{ pulp_site_install_dir }}/containers:/var/lib/containers{{ _pulp_site_selinux_suffix }}"
3434
device: /dev/fuse
3535
image: docker.io/pulp/pulp:3.68.1
3636
state: present
3737

3838
- name: Create systemd file
39-
copy:
39+
ansible.builtin.copy:
4040
src: pulp.service
4141
dest: /etc/systemd/system/pulp.service
42+
mode: "0644"
4243
register: _pulp_service
43-
44+
4445
- name: Start Pulp service
45-
systemd:
46+
ansible.builtin.systemd:
4647
name: pulp
4748
state: "{{ 'started' if _pulp_service.changed else 'restarted' }}"
4849
daemon_reload: "{{ _pulp_service.changed }}"
4950
enabled: true
50-
51-
- name: Reset admin password once container has initialised
51+
52+
- name: Reset admin password once container has initialised # noqa: no-changed-when
5253
no_log: true
5354
ansible.builtin.command:
5455
cmd: "podman exec pulp bash -c 'pulpcore-manager reset-admin-password -p {{ pulp_site_password }}'"

0 commit comments

Comments
 (0)