Pulp CLI
Pulp CLI is a command-line interface for managing Pulp 3 resources and interacting with Pulpcore's REST API. It serves as a client for various Pulp plugins (e.g., pulp_ansible, pulp_file, pulp_rpm) to perform tasks like listing repositories, synchronizing content, and managing distributions. Currently at version 0.39.0, the library is under active development, and its status is considered 'beta', implying that future releases may introduce backwards-incompatible changes.
Common errors
-
Error: Call aborted due to safe mode
cause Attempting to perform a write or modify operation (e.g., `pulp rpm repository update`) when the Pulp CLI, or the underlying Pulp server, is configured in a read-only 'safe mode' for that operation context.fixIf the operation is intended and safe mode can be overridden, append the `--force` global option to your Pulp CLI command (e.g., `pulp --force rpm repository update ...`). -
Error: {'detail': 'Authentication credentials were not provided.'}cause The Pulp CLI failed to authenticate with the Pulp server. This can be due to incorrect username/password, missing API tokens, issues with client certificates, or an inaccessible identity provider.fixVerify that your `~/.config/pulp/cli.toml` or environment variables (e.g., `PULP_USERNAME`, `PULP_PASSWORD`, `PULP_TOKEN`) contain correct and active credentials. If using client certificates, ensure `--cert` and `--key` paths are correct and the server accepts them. Test basic connectivity with `pulp status`, which doesn't require authentication. -
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
cause The Python environment or Pulp CLI is unable to verify the SSL certificate of the Pulp server, often because the server uses a self-signed certificate or a CA certificate not trusted by the client system.fixProvide the path to your CA certificate bundle using the `--ca-cert` global option (e.g., `pulp --ca-cert /path/to/ca.crt ...`) or by setting the `PULP_CA_BUNDLE` environment variable. Alternatively, for testing *only*, you can disable SSL verification with `--no-verify-ssl` (not recommended for production).
Warnings
- breaking Pulp CLI is currently in 'beta' status. Future releases may introduce backwards-incompatible changes, which could break existing scripts or automation.
- gotcha For certain integrations, Pulp CLI is primarily read-only. Attempts to perform write operations (add, update, delete content) may result in an 'Error: Call aborted due to safe mode' message and a non-zero exit code.
- deprecated Several options for `pulp_rpm` commands, including `--package-checksum-type`, `--metadata-checksum-type`, `--gpgcheck`, and `--repo-gpgcheck`, have been removed in version 0.33.0.
Install
-
pip install pulp-cli -
pip install pulp-cli[pygments]
Quickstart
import os
# Configure Pulp CLI. This creates or updates ~/.config/pulp/cli.toml
# In a real scenario, avoid hardcoding credentials. Use environment variables or a .netrc file.
# Example using environment variables:
# export PULP_BASE_URL="http://localhost:8080"
# export PULP_USERNAME="admin"
# export PULP_PASSWORD="password"
base_url = os.environ.get('PULP_BASE_URL', 'http://localhost:8080')
username = os.environ.get('PULP_USERNAME', 'admin')
password = os.environ.get('PULP_PASSWORD', 'password')
# This command is meant to be run in a shell, not directly via Python subprocess
# For demonstration, it's shown as a shell command.
print(f"Setting up Pulp CLI configuration for {base_url}...")
print(f"pulp config create --base-url {base_url} --username {username} --password {password}")
# To verify connection and list available repositories
print("\nVerifying Pulp server status:")
print("pulp status")
print("\nListing file repositories (example):")
print("pulp file repository list")
# To see full help for a command:
print("\nTo view full help for the 'pulp' command:")
print("pulp --help")