Skip to content

Commit 83161c7

Browse files
committed
Merge branch 'feat/pulp-builds' into feat/extra-packages
2 parents 34fee1c + 18b220e commit 83161c7

File tree

9 files changed

+54
-41
lines changed

9 files changed

+54
-41
lines changed

ansible/adhoc/deploy-pulp.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
become: yes
1212
hosts: _pulp_host
1313
tasks:
14-
1514
- name: Install pulp
1615
ansible.builtin.include_role:
1716
name: pulp_site

ansible/roles/dnf_repos/defaults/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ dnf_repos_password: "{{ omit }}"
88
dnf_repos_repolist:
99
- file: rocky
1010
name: baseos
11-
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/BaseOS/{{ ansible_architecture }}/os/{{ appliances_repo_minor_timestamps[ansible_distribution_version].baseos }}"
11+
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/BaseOS/{{ ansible_architecture }}/os/{{ appliances_repo_timestamps.baseos[ansible_distribution_version] }}"
1212
- file: rocky
1313
name: appstream
14-
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/AppStream/{{ ansible_architecture }}/os/{{ appliances_repo_minor_timestamps[ansible_distribution_version].appstream }}"
14+
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/AppStream/{{ ansible_architecture }}/os/{{ appliances_repo_timestamps.appstream[ansible_distribution_version] }}"
1515
- file: rocky
1616
name: crb
17-
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/CRB/{{ ansible_architecture }}/os/{{ appliances_repo_minor_timestamps[ansible_distribution_version].crb }}"
17+
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/CRB/{{ ansible_architecture }}/os/{{ appliances_repo_timestamps.crb[ansible_distribution_version] }}"
1818
- file: rocky-extras
1919
name: extras
20-
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/extras/{{ ansible_architecture }}/os/{{ appliances_repo_minor_timestamps[ansible_distribution_version].extras }}"
20+
base_url: "{{ dnf_repos_pulp_content_url }}/{{ dnf_repos_rocky_prefix }}/extras/{{ ansible_architecture }}/os/{{ appliances_repo_timestamps.extras[ansible_distribution_version] }}"
2121

22-
dnf_repos_epel_baseurl: "{{ dnf_repos_pulp_content_url }}/epel/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/{{ appliances_repo_major_timestamps[ansible_distribution_major_version].epel }}"
22+
dnf_repos_epel_baseurl: "{{ dnf_repos_pulp_content_url }}/epel/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/{{ appliances_repo_timestamps.epel[ansible_distribution_major_version] }}"
2323
dnf_repos_epel_description: "epel"

ansible/roles/pulp_site/defaults/main.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
pulp_site_url: "{{ appliances_pulp_url }}"
22
pulp_site_port: 8080
33
pulp_site_username: admin # shouldn't be changed
4+
pulp_site_password: "{{ vault_pulp_admin_password }}"
45
pulp_site_upstream_content_url: https://ark.stackhpc.com/pulp/content
5-
pulp_site_upstream_username: slurm-app-ci
6-
pulp_site_upstream_password: "{{ lookup('ansible.builtin.env', 'ARK_PASSWORD') }}"
76
_pulp_site_rocky_prefix: "{{ pulp_site_target_distribution }}/{{ pulp_site_target_distribution_version }}"
87
pulp_site_default_upstream_suffix: "{{ pulp_site_target_arch }}/os"
9-
pulp_site_password: "{{ vault_pulp_admin_password }}"
108
pulp_site_validate_certs: false
119
pulp_site_install_dir: '/home/rocky/pulp'
1210
pulp_site_selinux_suffix: "{{ ':Z' if ansible_selinux.status == 'enabled' else '' }}"
@@ -15,20 +13,18 @@ pulp_site_target_arch: "{{ pulp_site_target_facts['architecture'] }}"
1513
pulp_site_target_distribution: "{{ pulp_site_target_facts['distribution'] | lower }}"
1614
pulp_site_target_distribution_version: "{{ pulp_site_target_facts['distribution_version'] }}"
1715
pulp_site_target_distribution_version_major: "{{ pulp_site_target_facts['distribution_major_version'] }}"
18-
pulp_site_version_timestamps: "{{ appliances_repo_minor_timestamps[pulp_site_target_distribution_version] }}"
19-
pulp_site_major_version_timestamps: "{{ appliances_repo_major_timestamps[pulp_site_target_distribution_version_major] }}"
2016

2117
pulp_site_rpm_info:
22-
- name: "baseos-{{ pulp_site_target_distribution_version }}-{{ pulp_site_version_timestamps.baseos }}"
23-
subpath: "{{ _pulp_site_rocky_prefix }}/BaseOS/{{ pulp_site_default_upstream_suffix }}/{{ pulp_site_version_timestamps.baseos }}"
24-
- name: "appstream-{{ pulp_site_target_distribution_version }}-{{ pulp_site_version_timestamps.appstream }}"
25-
subpath: "{{ _pulp_site_rocky_prefix }}/AppStream/{{ pulp_site_default_upstream_suffix }}/{{ pulp_site_version_timestamps.appstream }}"
26-
- name: "crb-{{ pulp_site_target_distribution_version }}-{{ pulp_site_version_timestamps.crb }}"
27-
subpath: "{{ _pulp_site_rocky_prefix }}/{{ 'PowerTools' if pulp_site_target_distribution_version_major == '8' else 'CRB' }}/{{ pulp_site_default_upstream_suffix }}/{{ pulp_site_version_timestamps.crb }}"
28-
- name: "extras-{{ pulp_site_target_distribution_version }}-{{ pulp_site_version_timestamps.extras }}"
29-
subpath: "{{ _pulp_site_rocky_prefix }}/extras/{{ pulp_site_default_upstream_suffix }}/{{ pulp_site_version_timestamps.extras }}"
30-
- name: "epel-{{ pulp_site_target_distribution_version_major }}-{{ pulp_site_major_version_timestamps.epel }}"
31-
subpath: "epel/{{ pulp_site_target_distribution_version_major }}/Everything/{{ pulp_site_target_arch }}/{{ pulp_site_major_version_timestamps.epel }}"
18+
- name: "baseos-{{ pulp_site_target_distribution_version }}-{{ appliances_repo_timestamps.baseos[pulp_site_target_distribution_version] }}"
19+
subpath: "{{ _pulp_site_rocky_prefix }}/BaseOS/{{ pulp_site_default_upstream_suffix }}/{{ appliances_repo_timestamps.baseos[pulp_site_target_distribution_version] }}"
20+
- name: "appstream-{{ pulp_site_target_distribution_version }}-{{ appliances_repo_timestamps.appstream[pulp_site_target_distribution_version] }}"
21+
subpath: "{{ _pulp_site_rocky_prefix }}/AppStream/{{ pulp_site_default_upstream_suffix }}/{{ appliances_repo_timestamps.appstream[pulp_site_target_distribution_version] }}"
22+
- name: "crb-{{ pulp_site_target_distribution_version }}-{{ appliances_repo_timestamps.crb[pulp_site_target_distribution_version] }}"
23+
subpath: "{{ _pulp_site_rocky_prefix }}/{{ 'PowerTools' if pulp_site_target_distribution_version_major == '8' else 'CRB' }}/{{ pulp_site_default_upstream_suffix }}/{{ appliances_repo_timestamps.crb[pulp_site_target_distribution_version] }}"
24+
- name: "extras-{{ pulp_site_target_distribution_version }}-{{ appliances_repo_timestamps.extras[pulp_site_target_distribution_version] }}"
25+
subpath: "{{ _pulp_site_rocky_prefix }}/extras/{{ pulp_site_default_upstream_suffix }}/{{ appliances_repo_timestamps.extras[pulp_site_target_distribution_version] }}"
26+
- name: "epel-{{ pulp_site_target_distribution_version_major }}-{{ appliances_repo_timestamps.epel[pulp_site_target_distribution_version_major] }}"
27+
subpath: "epel/{{ pulp_site_target_distribution_version_major }}/Everything/{{ pulp_site_target_arch }}/{{ appliances_repo_timestamps.epel[pulp_site_target_distribution_version_major] }}"
3228

3329
pulp_site_rpm_repo_defaults:
3430
remote_username: "{{ pulp_site_upstream_username }}"

docs/experimental/pulp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Pulp Server
22

3-
In order to ensure reproducible builds, the appliance can build images using repository mirrors from StackHPC's Ark Pulp server. The appliance will sync relevant repositories to local Pulp server which will be used for image builds. Using a local server can be enabled by adding `pulp` to the build groups and overriding `dnf_repos_repolist` to point at content hosted on the local server.
3+
In order to ensure reproducible builds, the appliance can build images using repository mirrors from StackHPC's "Ark" Pulp server. The appliance can sync relevant repositories to a local Pulp server which will then be used instead of Ark. Using a local Pulp can be enabled by adding `pulp` to the build groups and overriding `appliances_pulp_url` to point at the local Pulp's URL.
44

55
## Deploying/configuring Pulp Server
66

77
### Deploying a Pulp server
88
A playbook is provided to install and configure a Pulp server on a given host. Admin credentials for this server are automatically generated through the `ansible/adhoc/generate-passwords.yml' playbook. This can be run with
9-
`ansible-playbook ansible/adhoc/deploy-pulp.yml -e "pulp_server=<host_ip>"`
10-
This will print a Pulp endpoint which can be copied to your environments as appropriate. Ensure that the server is accessible on the specified port. Note that this server's content isn't authenticated so assumes the server is deployed behind a secure network.
9+
`ansible-playbook ansible/adhoc/deploy-pulp.yml -e "pulp_server=<target_host>"`
10+
where `target_host` is any resolvable host. This will print a Pulp URL which can be copied to your environments as appropriate. Ensure that the server is accessible on the specified port. Note access to this server's content isn't authenticated so assumes the server is deployed behind a secure network.
1111

1212
### Using an existing Pulp server
1313
An existing Pulp server can be used to host Ark repos by overriding `pulp_site_password` and `appliances_pulp_url` in the target environment. Note that this assumes the same configuration as the appliance deployed pulp i.e no content authentication.
1414

1515
## Syncing Pulp content with Ark
1616

17-
If the `pulp` group is added to the Packer build groups, the local Pulp server will be synced with Ark on build. You must supply your Ark credentials, either by overriding `pulp_site_upstream_password` or setting environment variable `ARK_PASSWORD`. Content can also be synced by running `ansible/adhoc/sync-pulp.yml`, optionally setting extravars for `pulp_site_target_arch`, `pulp_site_target_distribution`, `pulp_site_target_distribution_version` and `pulp_site_target_distribution_version`.
17+
If the `pulp` group is added to the Packer build groups, the local Pulp server will be synced with Ark on build. You must authenticate with Ark by overriding `pulp_site_upstream_username` and `pulp_site_upstream_password` with your vault encrypted Ark dev credentials. `dnf_repos_username` and `dnf_repos_password` must remain unset to access content from the local Pulp. Content can also be synced by running `ansible/adhoc/sync-pulp.yml`. By default this syncs repositories for Rocky 9.4 with x86_64 architecture, but can be overriden by setting extravars for `pulp_site_target_arch`, `pulp_site_target_distribution`, `pulp_site_target_distribution_version` and `pulp_site_target_distribution_version_major`.

docs/image-build.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ The fat images StackHPC builds and tests in CI are available from [GitHub releas
1717
To build either a site-specific fat image from scratch, or to extend an existing StackHPC fat image:
1818

1919
1. Ensure the current OpenStack credentials have sufficient authorisation to upload images (this may or may not require the `member` role for an application credential, depending on your OpenStack configuration).
20-
2. Create a Packer [variable definition file](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#assigning-values-to-input-variables) at e.g. `environments/<environment>/builder.pkrvars.hcl` containing at a minimum:
20+
2. The provided dev credentials for StackHPC's "Ark" Pulp server must be added to the target environments. This is done by overriding `dnf_repos_username` and `dnf_repos_password` with your vault encrypted credentials in `environments/<base_environment>/inventory/group_vars/all/pulp.yml`. See the [experimental docs](experimental/pulp.md) if you wish instead wish to use a local Pulp server.
21+
3. Create a Packer [variable definition file](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#assigning-values-to-input-variables) at e.g. `environments/<environment>/builder.pkrvars.hcl` containing at a minimum:
2122

2223
```hcl
2324
flavor = "general.v1.small" # VM flavor to use for builder VMs
@@ -35,9 +36,9 @@ To build either a site-specific fat image from scratch, or to extend an existing
3536
- `update,control,login,compute`: The resultant image has all packages in the source image updated, and then packages for all types of nodes in the cluster are added. When using a GenericCloud image for `source_image_name` this builds a site-specific fat image from scratch.
3637
- One or more specific groups which are not enabled in the appliance by default, e.g. `lustre`. When using a StackHPC fat image for `source_image_name` this extends the image with just this additional functionality.
3738
38-
3. Activate the venv and the relevant environment.
39+
4. Activate the venv and the relevant environment.
3940
40-
4. Build images using the relevant variable definition file, e.g.:
41+
5. Build images using the relevant variable definition file, e.g.:
4142
4243
cd packer/
4344
PACKER_LOG=1 /usr/bin/packer build -on-error=ask -var-file=$PKR_VAR_environment_root/builder.pkrvars.hcl openstack.pkr.hcl
@@ -52,7 +53,7 @@ To build either a site-specific fat image from scratch, or to extend an existing
5253
5354
then delete the failed volume, select cancelling the build when Packer queries, and then retry. This is [Openstack bug 1823445](https://bugs.launchpad.net/cinder/+bug/1823445).
5455
55-
5. The built image will be automatically uploaded to OpenStack with a name prefixed `openhpc` and including a timestamp and a shortened git hash.
56+
6. The built image will be automatically uploaded to OpenStack with a name prefixed `openhpc` and including a timestamp and a shortened git hash.
5657
5758
# Build Process
5859

environments/.stackhpc/inventory/group_vars/builder.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
# appliances_pulp_url: "{{ pulp_server_config[lookup('env','CI_CLOUD')].url }}"
1111
# pulp_site_password: "{{ pulp_server_config[lookup('env','CI_CLOUD')].password }}"
1212

13+
# Alternatively, configure to use ark directly:
1314
dnf_repos_username: slurm-app-ci
1415
dnf_repos_password: "{{ lookup('env','ARK_PASSWORD') }}"
16+
17+
# Can be set regardless of approach above:
18+
pulp_site_upstream_username: slurm-app-ci
19+
pulp_site_upstream_password: "{{ lookup('ansible.builtin.env', 'ARK_PASSWORD') }}"

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ appliances_extra_packages: "{{ appliances_default_extra_packages + appliances_ot
103103

104104
###################### ark repo timestamps ###################################################
105105

106-
appliances_repo_minor_timestamps:
107-
'9.4':
108-
baseos: 20240816T002610
109-
appstream: 20240816T002610
110-
crb: 20240816T002610
111-
extras: 20240816T002610
112-
113-
appliances_repo_major_timestamps:
114-
'9':
115-
epel: 20240902T080424
106+
appliances_repo_timestamps:
107+
baseos:
108+
'9.4': 20240816T002610
109+
appstream:
110+
'9.4': 20240816T002610
111+
crb:
112+
'9.4': 20240816T002610
113+
extras:
114+
'9.4': 20240816T002610
115+
epel:
116+
'9': 20240902T080424
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
pulp_site_port: 8080
2+
3+
# If using Ark directly (no local Pulp server), override the following with Ark creds
4+
5+
# dnf_repos_username:
6+
# dnf_repos_password:
7+
8+
# If instead using local Pulp server, override below with Ark creds
9+
10+
# pulp_site_upstream_username:
11+
# pulp_site_upstream_password:

environments/common/inventory/groups

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@ freeipa_client
152152
# Hosts to replace system repos with Pulp repos
153153
builder
154154

155-
[pulp:children]
156-
# Hosts used to run Pulp API commands
155+
[pulp]
156+
# Add builder to this group to enable automatically syncing of pulp during image build
157+
# Warning: when using Ark directly rather than a local Pulp server, adding hosts other than `builder` risks leaking Ark creds

0 commit comments

Comments
 (0)