-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/ansible' into change-apiVersion
- Loading branch information
Showing
36 changed files
with
459 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Distributions are created asynchronously. Create one, and specify the repository that will | ||
# be served at the base path specified. | ||
pulp ansible distribution create --name "baz" --base-path "my_content" --repository "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Distributions are created asynchronously. Create one, and specify the repository version that will | ||
# be served at the base path specified. | ||
pulp ansible distribution create --name "bar" --base-path "some_content" --repository "foo" --version 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This script will execute the component scripts and ensure that the documented examples | ||
# work as expected. | ||
|
||
# From the _scripts directory, run with `source quickstart.sh` (source to preserve the environment | ||
# variables) | ||
source setup.sh | ||
|
||
echo "Role - Workflows" | ||
source repo.sh | ||
source distribution_repo.sh | ||
source distribution_repo_version.sh | ||
source remote.sh | ||
source sync.sh | ||
|
||
echo "Collection - Workflows" | ||
source remote-collection.sh | ||
source sync-collection.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Create a remote that syncs some versions of django into your repository. | ||
pulp ansible remote -t "collection" create \ | ||
--name "abar" \ | ||
--auth-url "https://sso.qa.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token" \ | ||
--token "$ANSIBLE_TOKEN_AUTH" \ | ||
--tls-validation false \ | ||
--url "https://cloud.redhat.com/api/automation-hub/" \ | ||
--requirements $'collections:\n - testing.ansible_testing_content' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Create a remote that syncs some versions of django into your repository. | ||
pulp ansible remote -t "collection" create \ | ||
--name "cbar" \ | ||
--url "https://galaxy-dev.ansible.com/" \ | ||
--requirements $'collections:\n - testing.ansible_testing_content' | ||
# If requirements are in a file | ||
# you can use the option '--requirements @<file_name>' instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Create a remote that syncs some versions of django into your repository. | ||
pulp ansible remote -t "role" create --name "bar" --url "https://galaxy.ansible.com/api/v1/roles/?owner__username=elastic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Start by creating a new repository named foo | ||
pulp ansible repository create --name "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
export BASE_ADDR=${BASE_ADDR:-http://pulp:80} | ||
|
||
if [ -z "$(pip freeze | grep pulp-cli)" ]; then | ||
echo "Installing pulp-cli" | ||
pip install pulp-cli[pygments] | ||
fi | ||
|
||
# Set up CLI config file | ||
if [ ! -f ~/.config/pulp/settings.toml ]; then | ||
echo "Configuring pulp-cli" | ||
mkdir -p ~/.config/pulp | ||
cat > ~/.config/pulp/cli.toml << EOF | ||
[cli] | ||
base_url = "$BASE_ADDR" | ||
verify_ssl = false | ||
format = "json" | ||
username = "admin" | ||
password = "password" | ||
EOF | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sync repository foo using remote cbar | ||
pulp ansible repository sync --name "foo" --remote "cbar" | ||
|
||
# Use the -b option to have the sync task complete in the background | ||
# e.g. pulp -b ansible repository sync --name "foo" --remote "cbar" | ||
|
||
# After the task is complete, it gives us a new repository version | ||
# Inspecting new repository version | ||
pulp ansible repository version show --repository "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sync repository foo using remote bar | ||
pulp ansible repository sync --name "foo" --remote "role:bar" | ||
|
||
# Use the -b option to have the sync task complete in the background | ||
# e.g. pulp -b ansible repository sync --name "foo" --remote "bar" | ||
|
||
# After the task is complete, it gives us a new repository version | ||
# Inspecting new repository version | ||
pulp ansible repository version show --repository "foo" --version 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
echo "Setting environment variables for default hostname/port for the API and the Content app" | ||
BASE_ADDR=${BASE_ADDR:-http://localhost:24817} | ||
REGISTRY_ADDR=${BASE_ADDR#*//} | ||
|
||
# Poll a Pulp task until it is finished. | ||
wait_until_task_finished() { | ||
echo "Polling the task until it has reached a final state." | ||
local task_url=$1 | ||
local timeout=10 | ||
while [ "$timeout" -gt 0 ] | ||
do | ||
local response=$(http $task_url) | ||
local state=$(jq -r .state <<< ${response}) | ||
jq . <<< "${response}" || exit 1 | ||
case ${state} in | ||
failed|canceled) | ||
echo "Task in final state: ${state}" | ||
exit 1 | ||
;; | ||
completed) | ||
echo "$task_url complete." | ||
break | ||
;; | ||
*) | ||
echo "Still waiting..." | ||
sleep 2 | ||
timeout=$(($timeout-1)) | ||
;; | ||
esac | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Create a task that will build a container image from a Containerfile." | ||
|
||
TASK_HREF=$(http --form POST :$REPO_HREF'build_image/' containerfile@./Containerfile \ | ||
artifacts="{\"$ARTIFACT_HREF\": \"foo/bar/example.txt\"}" | jq -r '.task') | ||
|
||
# Poll the task (here we use a function defined in docs/_scripts/base.sh) | ||
wait_until_task_finished $BASE_ADDR$TASK_HREF | ||
|
||
# After the task is complete, it gives us a new repository version | ||
echo "Set REPOVERSION_HREF from finished task." | ||
REPOVERSION_HREF=$(http $BASE_ADDR$TASK_HREF| jq -r '.created_resources | first') | ||
|
||
echo "Inspecting RepositoryVersion." | ||
http $BASE_ADDR$REPOVERSION_HREF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# remove the repository and its content from the current filesystem | ||
pulp container distribution destroy --name "test/fixture" | ||
pulp orphan cleanup --protection-time 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Create a Containerfile that expects foo/bar/example.txt inside /pulp_working_directory." | ||
|
||
echo 'FROM centos:7 | ||
# Copy a file using COPY statement. Use the relative path specified in the 'artifacts' parameter. | ||
COPY foo/bar/example.txt /inside-image.txt | ||
# Print the content of the file when the container starts | ||
CMD ["cat", "/inside-image.txt"]' >> Containerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Create a text file and upload it to Pulp" | ||
|
||
echo 'Hello world!' > example.txt | ||
|
||
ARTIFACT_HREF=$(http --form POST http://localhost/pulp/api/v3/artifacts/ \ | ||
file@./example.txt \ | ||
| jq -r '.pulp_href') | ||
|
||
echo "Inspecting new artifact." | ||
http $BASE_ADDR$ARTIFACT_HREF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIST_NAME=$(head /dev/urandom | tr -dc a-z | head -c5) | ||
DIST_BASE_PATH='test' | ||
|
||
# Distributions are created asynchronously. | ||
echo "Creating distribution \ | ||
(name=$DIST_NAME, base_path=$DIST_BASE_PATH repository=$REPO_HREF)." | ||
TASK_HREF=$(http POST $BASE_ADDR/pulp/api/v3/distributions/container/container/ \ | ||
name=$DIST_NAME \ | ||
base_path=$DIST_BASE_PATH \ | ||
repository=$REPO_HREF | jq -r '.task') | ||
|
||
# Poll the task (here we use a function defined in docs/_scripts/base.sh) | ||
wait_until_task_finished $BASE_ADDR$TASK_HREF | ||
|
||
echo "Setting DISTRIBUTION_HREF from the completed task." | ||
# DISTRIBUTION_HREF is the pulp-api HREF, not the content app href | ||
DISTRIBUTION_HREF=$(http $BASE_ADDR$TASK_HREF | jq -r '.created_resources | first') | ||
|
||
echo "Inspecting Distribution." | ||
http $BASE_ADDR$DISTRIBUTION_HREF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
set -euv | ||
|
||
# This script will execute the component scripts and ensure that the documented examples | ||
# work as expected. | ||
|
||
# From the _scripts directory, run with `source docs_check_sync_publish.sh` (source to preserve the | ||
# environment variables) | ||
source base.sh | ||
|
||
# Check Sync | ||
source repo.sh | ||
source remote.sh | ||
source sync.sh | ||
source distribution.sh | ||
source download_after_sync.sh | ||
|
||
# Check add/remove | ||
source second_repo.sh | ||
source recursive_add_tag.sh | ||
source recursive_remove_tag.sh | ||
|
||
# Check Copy | ||
source second_repo.sh | ||
source manifest_copy.sh | ||
|
||
source second_repo.sh | ||
source tag_copy.sh | ||
|
||
# Check tag/untag | ||
source image_tagging.sh | ||
source download_after_tagging.sh | ||
source image_untagging.sh | ||
|
||
# Check import/export | ||
source export_repository.sh | ||
source cleanup_export.sh | ||
source import_repository.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
CONTAINER_TAG='manifest_a' | ||
|
||
echo "Setting REGISTRY_PATH, which can be used directly with the Docker Client." | ||
REGISTRY_PATH=$(http $BASE_ADDR$DISTRIBUTION_HREF | jq -r '.registry_path') | ||
|
||
echo "Next we pull and run the image from pulp" | ||
echo "$REGISTRY_PATH:$CONTAINER_TAG" | ||
sudo docker login -u admin -p password $REGISTRY_PATH | ||
sudo docker run $REGISTRY_PATH:$CONTAINER_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
TAG_NAME='custom_tag' | ||
|
||
DIST_NAME=$(head /dev/urandom | tr -dc a-z | head -c5) | ||
DIST_BASE_PATH='tag' | ||
|
||
echo "Publishing the latest repository." | ||
TASK_URL=$(http POST $BASE_ADDR/pulp/api/v3/distributions/container/container/ \ | ||
name=$DIST_NAME base_path=$DIST_BASE_PATH repository=$REPO_HREF \ | ||
| jq -r '.task') | ||
|
||
wait_until_task_finished $BASE_ADDR$TASK_URL | ||
|
||
DISTRIBUTION_HREF=$(http $BASE_ADDR$TASK_URL \ | ||
| jq -r '.created_resources | first') | ||
REGISTRY_PATH=$(http $BASE_ADDR$DISTRIBUTION_HREF \ | ||
| jq -r '.registry_path') | ||
|
||
echo "Running ${REGISTRY_PATH}:${TAG_NAME}." | ||
sudo docker login -u admin -p password $REGISTRY_PATH | ||
sudo docker run $REGISTRY_PATH:$TAG_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
podman pull ghcr.io/pulp/test-fixture-1:manifest_a | ||
|
||
# push a tagged image to the registry | ||
podman login ${REGISTRY_ADDR} -u admin -p password --tls-verify=false | ||
podman tag ghcr.io/pulp/test-fixture-1:manifest_a \ | ||
${REGISTRY_ADDR}/test/fixture:manifest_a | ||
podman push ${REGISTRY_ADDR}/test/fixture:manifest_a --tls-verify=false | ||
|
||
# a repository of the push type is automatically created | ||
REPOSITORY_HREF=$(pulp container repository -t push show \ | ||
--name "test/fixture" | jq -r ".pulp_href") | ||
|
||
# export the repository to the directory '/tmp/exports/test-fixture' | ||
EXPORTER_HREF=$(http ${BASE_ADDR}/pulp/api/v3/exporters/core/pulp/ \ | ||
name=both repositories:="[\"${REPOSITORY_HREF}\"]" \ | ||
path=/tmp/exports/test-fixture | jq -r ".pulp_href") | ||
TASK_HREF=$(http POST ${BASE_ADDR}${EXPORTER_HREF}exports/ | jq -r ".task") | ||
wait_until_task_finished ${BASE_ADDR}${TASK_HREF} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
TAG_NAME='custom_tag' | ||
MANIFEST_DIGEST=$(http $BASE_ADDR'/pulp/api/v3/content/container/manifests/?repository_version='$REPOVERSION_HREF \ | ||
| jq -r '.results | first | .digest') | ||
|
||
echo "Tagging the manifest." | ||
TASK_URL=$(http POST $BASE_ADDR$REPO_HREF'tag/' tag=$TAG_NAME digest=$MANIFEST_DIGEST \ | ||
| jq -r '.task') | ||
|
||
wait_until_task_finished $BASE_ADDR$TASK_URL | ||
|
||
echo "Getting a reference to a newly created tag." | ||
CREATED_TAG=$(http $BASE_ADDR$TASK_URL \ | ||
| jq -r '.created_resources | .[] | select(test("content"))') | ||
|
||
echo "Display properties of the created tag." | ||
http $BASE_ADDR$CREATED_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
TAG_NAME='custom_tag' | ||
|
||
echo "Untagging a manifest which is labeled with ${TAG_NAME}" | ||
TASK_URL=$(http POST $BASE_ADDR$REPO_HREF'untag/' tag=$TAG_NAME \ | ||
| jq -r '.task') | ||
|
||
wait_until_task_finished $BASE_ADDR$TASK_URL | ||
|
||
echo "Getting a reference to all removed tags." | ||
REPO_VERSION=$(http $BASE_ADDR$TASK_URL \ | ||
| jq -r '.created_resources | first') | ||
REMOVED_TAGS=$(http $BASE_ADDR$REPO_VERSION \ | ||
| jq -r '.content_summary | .removed | ."container.tag" | .href') | ||
|
||
echo "List removed tags from the latest repository version." | ||
http $BASE_ADDR$REMOVED_TAGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
# create a repository with the same name as the exported one | ||
http ${BASE_ADDR}/pulp/api/v3/repositories/container/container/ \ | ||
name="test/fixture" | jq -r ".pulp_href" | ||
|
||
# import the exported repository stored in '/tmp/exports/test-fixture' | ||
IMPORTER_HREF=$(http ${BASE_ADDR}/pulp/api/v3/importers/core/pulp/ \ | ||
name="test/fixture" | jq -r ".pulp_href") | ||
EXPORTED_REPO_PATH=$(find "/tmp/exports/test-fixture" -type f -name \ | ||
"*.tar.gz" | head -n 1) | ||
GROUP_HREF=$(http ${BASE_ADDR}${IMPORTER_HREF}imports/ \ | ||
path=${EXPORTED_REPO_PATH} | jq -r ".task_group") | ||
echo ${BASE_ADDR}${GROUP_HREF} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Create a task to copy all manifests from source to destination repo." | ||
TASK_HREF=$(http POST $BASE_ADDR$SECOND_REPO_HREF'copy_manifests/' \ | ||
source_repository=$REPO_HREF \ | ||
| jq -r '.task') | ||
|
||
# Poll the task (here we use a function defined in docs/_scripts/base.sh) | ||
wait_until_task_finished $BASE_ADDR$TASK_HREF | ||
|
||
# After the task is complete, it gives us a new repository version | ||
MANIFEST_COPY_VERSION=$(http $BASE_ADDR$TASK_HREF | jq -r '.created_resources | first') | ||
|
||
echo "Inspect RepositoryVersion." | ||
http $BASE_ADDR$MANIFEST_COPY_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Retrieve the href of Tag manifest_a in the synced repository." | ||
TAG_HREF=$(http $BASE_ADDR'/pulp/api/v3/content/container/tags/?repository_version='$REPOVERSION_HREF'&name=manifest_a' \ | ||
| jq -r '.results | first | .pulp_href') | ||
|
||
echo "Create a task to recursively add a tag to the repo." | ||
TASK_HREF=$(http POST $BASE_ADDR$SECOND_REPO_HREF'add/' \ | ||
content_units:="[\"$TAG_HREF\"]" \ | ||
| jq -r '.task') | ||
|
||
# Poll the task (here we use a function defined in docs/_scripts/base.sh) | ||
wait_until_task_finished $BASE_ADDR$TASK_HREF | ||
|
||
# After the task is complete, it gives us a new repository version | ||
ADDED_VERSION=$(http $BASE_ADDR$TASK_HREF| jq -r '.created_resources | first') | ||
|
||
echo "Inspect RepositoryVersion." | ||
http $BASE_ADDR$ADDED_VERSION |
Oops, something went wrong.