Publish and Host¶
This section assumes that you have a repository called foo
with content in it. To do this, see the
Synchronize a Repository or Upload and Manage Content documentation.
Create a Publication¶
Create a publication from the latest repository version. This prepares the
meta-data needed to distribute the content of the repository on a /universe
endpoint. However, creating a publication distributes no content to the outside.
This has to be done in a separate step.
export REPO_HREF=$(http $BASE_ADDR/pulp/api/v3/repositories/cookbook/cookbook/?name=foo | jq -r '.results[0].pulp_href')
export LATEST_VERSION_HREF=$(http $BASE_ADDR$REPO_HREF | jq -r '.latest_version_href')
task_result=$(pulp_http POST $BASE_ADDR/pulp/api/v3/publications/cookbook/cookbook/ repository_version=$LATEST_VERSION_HREF)
echo "$task_result"
export PUBLICATION_HREF=$(echo "$task_result" | jq -r '.created_resources[0]')
Response:
{
"child_tasks": [],
"created_resources": [
"/pulp/api/v3/publications/cookbook/cookbook/a477ab9e-79e1-4fe8-a56c-dbd31e629afe/"
],
"error": null,
"finished_at": "2020-08-31T18:56:04.875990Z",
"name": "pulp_cookbook.app.tasks.publishing.publish",
"parent_task": null,
"progress_reports": [
{
"code": "publishing.content",
"done": 18,
"message": "Publishing Content",
"state": "completed",
"suffix": null,
"total": null
}
],
"pulp_created": "2020-08-31T18:56:04.575918Z",
"pulp_href": "/pulp/api/v3/tasks/9bd500b9-3a5e-4a80-a8f1-77b086f48fa6/",
"reserved_resources_record": [
"/pulp/api/v3/repositories/cookbook/cookbook/84be8c38-0889-4135-81c5-3ebb7a490e20/"
],
"started_at": "2020-08-31T18:56:04.775986Z",
"state": "completed",
"task_group": null,
"worker": "/pulp/api/v3/workers/7a1130eb-8483-418f-a370-cecf0e63f60b/"
}
Create a Distribution foo
for the Publication¶
Actually distribute the publication created in the last step at a specific path.
The base path is foo
in this case. The publication will be distributed at
/pulp_cookbook/content/foo/universe
on the content endpoint (which is on
port 24816 in our example).
pulp_http POST $BASE_ADDR/pulp/api/v3/distributions/cookbook/cookbook/ name='foo' base_path='foo' publication=$PUBLICATION_HREF
export DISTRIBUTION_HREF=$(http $BASE_ADDR/pulp/api/v3/distributions/cookbook/cookbook/?name=foo | jq -r '.results[0].pulp_href')
Response:
{
"child_tasks": [],
"created_resources": [
"/pulp/api/v3/distributions/cookbook/cookbook/4bbbb105-f466-4ba5-ba6a-fbe057628534/"
],
"error": null,
"finished_at": "2020-08-31T18:56:06.166432Z",
"name": "pulpcore.app.tasks.base.general_create",
"parent_task": null,
"progress_reports": [],
"pulp_created": "2020-08-31T18:56:05.823671Z",
"pulp_href": "/pulp/api/v3/tasks/3b12f649-46f0-471c-be40-7596fd2c9b04/",
"reserved_resources_record": [
"/api/v3/distributions/"
],
"started_at": "2020-08-31T18:56:06.032185Z",
"state": "completed",
"task_group": null,
"worker": "/pulp/api/v3/workers/714038d7-7077-43c5-b980-c9be814dcaa0/"
}
You can have a look at the published “universe” metadata now:
pulp_http $CONTENT_ADDR/pulp_cookbook/content/foo/universe
Response:
{
"pulp": {
"0.1.1": {
"dependencies": {
"qpid": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/pulp/0_1_1/pulp-0.1.1.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/pulp/0_1_1/pulp-0.1.1.tar.gz",
"location_type": "uri"
}
},
"qpid": {
"0.1.3": {
"dependencies": {
"yum": ">= 0.0.0",
"yum-epel": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/qpid/0_1_3/qpid-0.1.3.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/qpid/0_1_3/qpid-0.1.3.tar.gz",
"location_type": "uri"
}
},
"ubuntu": {
"0.7.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/0_7_0/ubuntu-0.7.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/0_7_0/ubuntu-0.7.0.tar.gz",
"location_type": "uri"
},
"0.99.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/0_99_0/ubuntu-0.99.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/0_99_0/ubuntu-0.99.0.tar.gz",
"location_type": "uri"
},
"1.0.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_0_0/ubuntu-1.0.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_0_0/ubuntu-1.0.0.tar.gz",
"location_type": "uri"
},
"1.1.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_0/ubuntu-1.1.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_0/ubuntu-1.1.0.tar.gz",
"location_type": "uri"
},
"1.1.2": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_2/ubuntu-1.1.2.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_2/ubuntu-1.1.2.tar.gz",
"location_type": "uri"
},
"1.1.4": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_4/ubuntu-1.1.4.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_4/ubuntu-1.1.4.tar.gz",
"location_type": "uri"
},
"1.1.6": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_6/ubuntu-1.1.6.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_6/ubuntu-1.1.6.tar.gz",
"location_type": "uri"
},
"1.1.8": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_8/ubuntu-1.1.8.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_1_8/ubuntu-1.1.8.tar.gz",
"location_type": "uri"
},
"1.2.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_2_0/ubuntu-1.2.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_2_0/ubuntu-1.2.0.tar.gz",
"location_type": "uri"
},
"1.2.1": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_2_1/ubuntu-1.2.1.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/1_2_1/ubuntu-1.2.1.tar.gz",
"location_type": "uri"
},
"2.0.0": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/2_0_0/ubuntu-2.0.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/2_0_0/ubuntu-2.0.0.tar.gz",
"location_type": "uri"
},
"2.0.1": {
"dependencies": {
"apt": ">= 0.0.0"
},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/2_0_1/ubuntu-2.0.1.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/2_0_1/ubuntu-2.0.1.tar.gz",
"location_type": "uri"
},
"3.0.0": {
"dependencies": {},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_0/ubuntu-3.0.0.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_0/ubuntu-3.0.0.tar.gz",
"location_type": "uri"
},
"3.0.1": {
"dependencies": {},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_1/ubuntu-3.0.1.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_1/ubuntu-3.0.1.tar.gz",
"location_type": "uri"
},
"3.0.2": {
"dependencies": {},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_2/ubuntu-3.0.2.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_2/ubuntu-3.0.2.tar.gz",
"location_type": "uri"
},
"3.0.3": {
"dependencies": {},
"download_url": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_3/ubuntu-3.0.3.tar.gz",
"location_path": "http://pulp3-source-fedora32.gandalf.example.com/pulp_cookbook/content/foo/cookbook_files/ubuntu/3_0_3/ubuntu-3.0.3.tar.gz",
"location_type": "uri"
}
}
}
Use Berkshelf with the published repo¶
Create a Berksfile
with the following content:
source 'http://localhost/pulp_cookbook/content/foo/'
cookbook 'ubuntu'
And run:
$ berks install
Resolving cookbook dependencies...
Fetching cookbook index from http://localhost:24816/pulp_cookbook/content/foo/...
Installing apt (7.0.0) from http://localhost:24816/pulp_cookbook/content/foo/ ([uri] http://localhost:24816/pulp_cookbook/content/foo/cookbook_files/apt/7_0_0/apt-7.0.0.tar.gz)
Installing ubuntu (2.0.1) from http://localhost:24816/pulp_cookbook/content/foo/ ([uri] http://localhost:24816/pulp_cookbook/content/foo/cookbook_files/ubuntu/2_0_1/ubuntu-2.0.1.tar.gz)