Exposing Content

Overview

Content, e.g. rpms or docker/oci containers, loaded into Pulp is only served by Pulp if made available through a Distribution. There are three options available to plugin writers.

  • Auto-distribution of a Repository

  • Manual distribution of a RepositoryVersion

  • Manual distribution of a Publication

The three workflows cannot be used together. Typically a plugin and that plugin’s users will use either the repository and repository_version options or publication but not both. It comes down to whether a plugin uses a Publication or not. If it does, it will use the publication attribute. If not, it can use the repository or repository_version attributes.

Distributions have a base_path which is the portion of the URL a given Distribution will be rooted at. There is also a Pulp configured setting called CONTENT_PATH_PREFIX which defaults to /pulp/content/. With this default a Distribution’s URL with base_path of someexample or a/nested/example can be expected respectively:

/pulp/content/someexample/
/pulp/content/a/nested/example/

Note

The base_path must have no overlapping components. So if a Distribution with base_path of a/path/foo existed, you could not make a second Distribution with a base_path of a/path or a because both are subpaths of a/path/foo. Pulp will stop you from doing this which is why Distribution creates or updates to base_path are run serially by the tasking system.

Auto-Distribution of a Repository

In this workflow you pair a Repository and a Distribution such that the Distribution will serve the latest RepositoryVersion associated with that Repository.

First lets make a Repository named foo and save its URL as REPO_HREF:

http POST http://localhost:24817/pulp/api/v3/repositories/container/container/ name=foo
export REPO_HREF=$(http :24817/pulp/api/v3/repositories/container/container/ | jq -r '.results[] | select(.name == "foo") | .pulp_href')

Then lets make a Distribution that will distribute foo at base_url mypath:

http POST :24817/pulp/api/v3/distributions/container/container/ name='baz' base_path='mypath' repository=$REPO_HREF``

As soon as this is created, any RepositoryVersion created will be immediately available at base_path mypath. With the default CONTENT_PATH_PREFIX that would be /pulp/content/mypath/

Note

This is only available for plugins that do not require a Publication. A Publication is required for content types that have “metadata”. See your plugin documentation for details on if it uses a Publication or not.

Manual Distribution of a RepositoryVersion

In this workflow, you already have a RepositoryVersion created. You then want to distribute its content at the base_path mypath using a Distribution. In this case you manually associate the Distribution with the RepositoryVersion using the repository_version option of the Distribution.

First create a RepositoryVersion with some pulp_ansible content in it:

# Create a Repository
http POST :24817/pulp/api/v3/repositories/ansible/ansible/ name=foo
export REPO_HREF=$(http :24817/pulp/api/v3/repositories/ansible/ansible/ | jq -r '.results[] | select(.name == "foo") | .pulp_href')

# Create an AnsibleRemote to sync roles from galaxy.ansible.com
http POST :24817/pulp/api/v3/remotes/ansible/ansible/ name=bar url='https://galaxy.ansible.com/api/v1/roles/?namespace__name=elastic'

export REMOTE_HREF=$(http :24817/pulp/api/v3/remotes/ansible/ansible/ | jq -r '.results[] | select(.name == "bar") | .pulp_href')

# Sync the repo with the remote
http POST ':24817'$REPO_HREF'sync/' remote=$REMOTE_HREF
sleep 3  # wait for the sync to happen
export REPO_VERSION_HREF=$(http GET ':24817'$REPO_HREF'versions/1/' | jq -r '.pulp_href')

Now with your RepositoryVersion saved as REPO_VERSION_HREF you can have the Distribution serve it at base_path dev:

http POST :24817/pulp/api/v3/distributions/file/file/ name='baz' base_path='dev' repository_version=REPO_VERSION_HREF

As soon as this is created, the RepositoryVersion will be immediately available at base_path dev. With the default CONTENT_PATH_PREFIX that would be /pulp/content/dev/

Note

This is only available for plugins that do not require a Publication. A Publication is required for content types that have “metadata”. See your plugin documentation for details on if it uses a Publication or not.

Manual Distribution of a Publication

In this workflow, you already have a Publication created. You then want to distribute its content at the base_path mypath using a Distribution. In this case you manually associate the Distribution with the Publication using the publication option of the Distribution.

First create a Publication with some pulp_file content in it:

# Create a Repository
http POST :24817/pulp/api/v3/repositories/file/file/ name=foo
export REPO_HREF=$(http :24817/pulp/api/v3/repositories/file/file/ | jq -r '.results[] | select(.name == "foo") | .pulp_href')

# Create an FileRemote to sync roles from fixures
http POST :24817/pulp/api/v3/remotes/file/file/ name='bar' url='https://fixtures.pulpproject.org/file/PULP_MANIFEST'
export REMOTE_HREF=$(http :24817/pulp/api/v3/remotes/file/file/ | jq -r '.results[] | select(.name == "bar") | .pulp_href')

# Sync the repo with the remote
http POST ':24817'$REPO_HREF'sync/' remote=$REMOTE_HREF
sleep 3  # wait for the sync to happen

# Create a Publication
http POST :24817/pulp/api/v3/publications/file/file/ repository=$REPO_HREF
export PUBLICATION_HREF=$(http :24817/pulp/api/v3/publications/file/file/ | jq -r '.results[0] | .pulp_href')

Now with your Publication saved as PUBLICATION_HREF you can have the Distribution serve it at base_path bar:

http POST :24817/pulp/api/v3/distributions/file/file/ name='baz' base_path='bar' publication=$PUBLICATION_HREF

As soon as this is created, the Publication will be immediately available at base_path bar. With the default CONTENT_PATH_PREFIX that would be /pulp/content/bar/