Skip to content

Commit

Permalink
add pulp services
Browse files Browse the repository at this point in the history
  • Loading branch information
archanaserver committed Oct 23, 2024
1 parent 2df4338 commit 73ba9dc
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 3 deletions.
17 changes: 17 additions & 0 deletions roles/pulp/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
---
pulp_image: quay.io/pulp/pulp:stable
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_ports:
- "8080:80"

pulp_api_ports:
- "24817:80"

pulp_content_ports:
- "24816:80"

pulp_worker_count: 2

pulp_volumes:
- /var/lib/pulp/settings:/etc/pulp:Z
- /var/lib/pulp/pulp_storage:/var/lib/pulp:Z
- /var/lib/pulp/pgsql:/var/lib/pgsql:Z
- /var/lib/pulp/containers:/var/lib/containers:Z

pulp_container_name: pulp
pulp_api_container_name: pulp-api
pulp_content_container_name: pulp-content
pulp_worker_container_name: pulp-worker
4 changes: 4 additions & 0 deletions roles/pulp/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
99 changes: 99 additions & 0 deletions roles/pulp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
name: "{{ pulp_image }}"
state: present

- name: Pull the Pulp API container image
containers.podman.podman_image:
name: "{{ pulp_api_image }}"
state: present

- name: Pull the Pulp Content container image
containers.podman.podman_image:
name: "{{ pulp_content_image }}"
state: present

- name: Pull the Pulp Worker container image
containers.podman.podman_image:
name: "{{ pulp_worker_image }}"
state: present

- name: Create Pulp storage
ansible.builtin.file:
path: "{{ item | split(':') | first }}"
Expand All @@ -24,6 +39,24 @@
volumes: "{{ pulp_volumes }}"
secrets:
- 'pulp-settings-py,type=mount,target=/etc/pulp/settings.py'
quadlet_options:
- |
[Install]
WantedBy=default.target
- name: Deploy Pulp API Container
containers.podman.podman_container:
name: "{{ pulp_api_container_name }}"
image: "{{ pulp_api_image }}"
state: quadlet
ports: "{{ pulp_api_ports }}"
volumes: "{{ pulp_volumes }}"
secrets:
- 'pulp-settings-py,type=mount,target=/etc/pulp/settings.py'
quadlet_options:
- |
[Install]
WantedBy=default.target
- name: Run daemon reload to make Quadlet create the service files
ansible.builtin.systemd:
Expand All @@ -41,6 +74,72 @@
port: 8080
timeout: 300

- name: Wait for Pulp API service to be accessible
wait_for:
host: "{{ ansible_hostname }}"
port: 24817
timeout: 600

- name: Deploy Pulp Content Container
containers.podman.podman_container:
name: "{{ pulp_content_container_name }}"
image: "{{ pulp_content_image }}"
state: quadlet
ports: "{{ pulp_content_ports }}"
volumes: "{{ pulp_volumes }}"
secrets:
- 'pulp-settings-py,type=mount,target=/etc/pulp/settings.py'
quadlet_options:
- |
[Unit]
After=network.target pulp-api.service
Requires=pulp-api.service
[Install]
WantedBy=default.target
- name: Deploy Pulp Worker Container
containers.podman.podman_container:
name: "{{ pulp_worker_container_name }}"
image: "{{ pulp_worker_image }}"
state: quadlet
volumes: "{{ pulp_volumes }}"
secrets:
- 'pulp-settings-py,type=mount,target=/etc/pulp/settings.py'
quadlet_options:
- |
After=network.target pulp-api.service pulp-content.service
Requires=pulp-api.service pulp-content.service
[Install]
WantedBy=default.target
- name: Run daemon reload to make Quadlet create the service files
ansible.builtin.systemd:
daemon_reload: true

- name: Start the Pulp API services
ansible.builtin.systemd:
name: pulp-api
enabled: true
state: started

- name: Start the Pulp Content services
ansible.builtin.systemd:
name: pulp-content
enabled: true
state: started

- name: Wait for Pulp Content service to be accessible
wait_for:
host: "{{ ansible_hostname }}"
port: 24816
timeout: 600

- name: Start the Pulp Worker service
ansible.builtin.systemd:
name: pulp-worker
enabled: true
state: started

# Only needed until we have cert auth configured
- name: Set Pulp admin password
containers.podman.podman_container_exec:
Expand Down
2 changes: 2 additions & 0 deletions roles/pulp/templates/settings.py.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CONTENT_ORIGIN="http://{{ ansible_hostname }}:8080"
API_CONTENT_ORIGIN="http://{{ ansible_hostname }}:24817"
CONTENT_SERVICE_ORIGIN="http://{{ ansible_hostname }}:24816"
CACHE_ENABLED=True
REDIS_HOST="localhost"
REDIS_PORT=6379
27 changes: 24 additions & 3 deletions tests/pulp_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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):
Expand All @@ -22,17 +22,38 @@ def test_pulp_service(host):
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
assert pulp_api.is_enabled

def test_pulp_content_service(host):
pulp_content = host.service("pulp-content")
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_api_port(host):
pulp_api = host.addr(PULP_HOST)
assert pulp_api.port(PULP_API_PORT).is_reachable

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']

Expand Down

0 comments on commit 73ba9dc

Please sign in to comment.