From dc25db2319455d2b7044e04e94804367176cc08a Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Mon, 4 Nov 2024 17:30:52 +0100 Subject: [PATCH] use right ports for pulp in http config --- roles/httpd/defaults/main.yml | 4 ++-- roles/pulp/defaults/main.yaml | 10 ++++----- roles/pulp/tasks/main.yaml | 5 ++++- roles/pulp/templates/settings.py.j2 | 5 ++--- tests/pulp_test.py | 33 ++++++++--------------------- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/roles/httpd/defaults/main.yml b/roles/httpd/defaults/main.yml index d3dd774..9339947 100644 --- a/roles/httpd/defaults/main.yml +++ b/roles/httpd/defaults/main.yml @@ -1,4 +1,4 @@ httpd_ssl_dir: /etc/pki/httpd -httpd_pulp_api_backend: http://localhost:8080 -httpd_pulp_content_backend: http://localhost:8080 +httpd_pulp_api_backend: http://localhost:24817 +httpd_pulp_content_backend: http://localhost:24816 httpd_foreman_backend: http://localhost:3000 diff --git a/roles/pulp/defaults/main.yaml b/roles/pulp/defaults/main.yaml index 2ded723..515f076 100644 --- a/roles/pulp/defaults/main.yaml +++ b/roles/pulp/defaults/main.yaml @@ -1,7 +1,8 @@ --- -pulp_api_image: quay.io/pulp/pulp-minimal:stable -pulp_content_image: quay.io/pulp/pulp-minimal:stable -pulp_worker_image: quay.io/pulp/pulp-minimal:stable +pulp_image: quay.io/pulp/pulp-minimal:stable +pulp_api_image: "{{ pulp_image }}" +pulp_content_image: "{{ pulp_image }}" +pulp_worker_image: "{{ pulp_image }}" pulp_api_ports: - "24817:80" @@ -10,8 +11,7 @@ pulp_content_ports: pulp_worker_count: 2 pulp_volumes: - - /var/lib/pulp/pulp_storage:/var/lib/pulp - - /var/lib/pulp/containers:/var/lib/containers + - /var/lib/pulp:/var/lib/pulp:Z pulp_api_container_name: pulp-api pulp_content_container_name: pulp-content diff --git a/roles/pulp/tasks/main.yaml b/roles/pulp/tasks/main.yaml index c25ae3d..97fbcaf 100644 --- a/roles/pulp/tasks/main.yaml +++ b/roles/pulp/tasks/main.yaml @@ -74,6 +74,7 @@ - | [Install] WantedBy=default.target + Wants=postgresql.service - name: Deploy Pulp Content Container containers.podman.podman_container: @@ -92,6 +93,7 @@ - | [Install] WantedBy=default.target + Wants=postgresql.service - name: Deploy Pulp Worker Container containers.podman.podman_container: @@ -110,6 +112,7 @@ - | [Install] WantedBy=default.target + Wants=postgresql.service - name: Run daemon reload to make Quadlet create the service files ansible.builtin.systemd: @@ -121,7 +124,7 @@ enabled: true state: started -- name: Migrate the Pylp database +- name: Migrate the Pulp database containers.podman.podman_container_exec: name: "{{ pulp_api_container_name }}" command: pulpcore-manager migrate --noinput diff --git a/roles/pulp/templates/settings.py.j2 b/roles/pulp/templates/settings.py.j2 index 97982fb..6b1f4b0 100644 --- a/roles/pulp/templates/settings.py.j2 +++ b/roles/pulp/templates/settings.py.j2 @@ -1,9 +1,8 @@ -CONTENT_ORIGIN="http://{{ ansible_hostname }}:8080" -API_CONTENT_ORIGIN="http://{{ ansible_hostname }}:24817" -CONTENT_SERVICE_ORIGIN="http://{{ ansible_hostname }}:24816" +CONTENT_ORIGIN="http://{{ ansible_hostname }}:24816" CACHE_ENABLED=True REDIS_HOST="localhost" REDIS_PORT=6379 +REDIS_DB=8 DATABASES = { 'default': { diff --git a/tests/pulp_test.py b/tests/pulp_test.py index 9fe7729..b7a5747 100644 --- a/tests/pulp_test.py +++ b/tests/pulp_test.py @@ -1,27 +1,18 @@ import json import pytest - PULP_HOST = 'localhost' -PULP_PORT = 8080 PULP_API_PORT = 24817 PULP_CONTENT_PORT = 24816 @pytest.fixture(scope="module") def pulp_status_curl(host): - return host.run(f"curl -k -s -w '%{{stderr}}%{{http_code}}' http://{PULP_HOST}:{PULP_PORT}/pulp/api/v3/status/") - + return host.run(f"curl -k -s -w '%{{stderr}}%{{http_code}}' http://{PULP_HOST}:{PULP_API_PORT}/pulp/api/v3/status/") @pytest.fixture(scope="module") def pulp_status(pulp_status_curl): return json.loads(pulp_status_curl.stdout) - -def test_pulp_service(host): - pulp = host.service("pulp") - assert pulp.is_running - assert pulp.is_enabled - def test_pulp_api_service(host): pulp_api = host.service("pulp-api") assert pulp_api.is_running @@ -32,15 +23,10 @@ def test_pulp_content_service(host): assert pulp_content.is_running assert pulp_content.is_enabled -def test_pulp_worker_services(host): - for i in range(1, 3): - pulp_worker = host.service(f"pulp-worker@{i}") - assert pulp_worker.is_running - assert pulp_worker.is_enabled - -def test_pulp_port(host): - pulp = host.addr(PULP_HOST) - assert pulp.port(PULP_PORT).is_reachable +def test_pulp_worker_service(host): + pulp_worker = host.service("pulp-worker") + assert pulp_worker.is_running + assert pulp_worker.is_enabled def test_pulp_api_port(host): pulp_api = host.addr(PULP_HOST) @@ -50,10 +36,6 @@ def test_pulp_content_port(host): pulp_content = host.addr(PULP_HOST) assert pulp_content.port(PULP_CONTENT_PORT).is_reachable -def test_pulp_status(pulp_status_curl): - assert pulp_status_curl.succeeded - assert pulp_status_curl.stderr == '200' - def test_pulp_status_database_connection(pulp_status): assert pulp_status['database_connection']['connected'] @@ -75,6 +57,9 @@ def test_pulp_status_workers(pulp_status): @pytest.mark.xfail(reason='password auth is deactivated when we use cert auth') def test_pulp_admin_auth(host): - cmd = host.run(f"curl --silent --write-out '%{{stderr}}%{{http_code}}' --user admin:CHANGEME http://{PULP_HOST}:{PULP_PORT}/pulp/api/v3/users/") + cmd = host.run(f"curl --silent --write-out '%{{stderr}}%{{http_code}}' --user admin:CHANGEME http://{PULP_HOST}:{PULP_API_PORT}/pulp/api/v3/users/") assert cmd.succeeded assert cmd.stderr == '200' + +def test_pulp_volumes(host): + assert host.file("/var/lib/pulp").is_directory