Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ See [docs/developer/playbooks-and-roles.md](docs/developer/playbooks-and-roles.m

Roles in `src/roles/` correspond to services and deployment stages:

- Service roles: `foreman`, `pulp`, `candlepin`, `postgresql`, `redis`, `httpd`
- Service roles: `foreman`, `pulp`, `candlepin`, `postgresql`, `valkey`, `httpd`
- Feature roles: `hammer`, `foreman_proxy`
- Infrastructure: `certificates`, `systemd_target`
- Lifecycle: `pre_install`, `post_install`
Expand Down
2 changes: 1 addition & 1 deletion development/playbooks/deploy-dev/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
- role: pre_install
- role: certificates
- role: postgresql
- role: redis
- role: valkey
- role: candlepin
- role: httpd
- role: pulp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Foreman Development Server
After=redis.service postgresql.service
Wants=redis.service postgresql.service
After=valkey.service postgresql.service
Wants=valkey.service postgresql.service

[Service]
Type=simple
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes how to set up and use the Foreman development environmen

The development environment provides:
- Git-based Foreman installation (cloned from GitHub)
- Containerized backend services (PostgreSQL, Redis, Candlepin, Pulp, Apache HTTP Server)
- Containerized backend services (PostgreSQL, Valkey, Candlepin, Pulp, Apache HTTP Server)
- Plugin support with registry system
- Development-specific configurations
- Direct Rails server access for debugging
Expand Down Expand Up @@ -128,7 +128,7 @@ After deployment, the environment includes:

The development environment integrates:
- **Apache HTTP Server**: Provides HTTPS proxy to the Rails development server
- **Backend Services**: All services (PostgreSQL, Redis, Candlepin, Pulp) run in containers
- **Backend Services**: All services (PostgreSQL, Valkey, Candlepin, Pulp) run in containers
- **Rails Development Server**: Runs directly on the VM for live debugging and development
- **Pulp Smart Proxy Registration**: Automatically configures Pulp integration during deployment
- **Hammer CLI**: Automatically sets up hammer for development, if `hammer` feature was enabled
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/playbooks-and-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Each directory under `playbooks/` becomes a CLI subcommand (e.g. `foremanctl dep
Roles live under `src/roles/` (production) and `development/roles/` (development).

- Use **lowercase with underscores** as separators: `postgresql`, `foreman_proxy`, `post_install`, `foreman_development`.
- Name roles after the service or concern they manage: `redis`, `httpd`, `certificates`, `systemd_target`.
- Name roles after the service or concern they manage: `valkey`, `httpd`, `certificates`, `systemd_target`.

## Shared Metadata Fragments

Expand Down
2 changes: 1 addition & 1 deletion docs/developer/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ For example:

```python
def test_service_running(server):
assert server.service("redis").is_running
assert server.service("valkey").is_running


def test_service_port(server):
Expand Down
2 changes: 1 addition & 1 deletion src/playbooks/deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- role: postgresql
when:
- database_mode == 'internal'
- redis
- valkey
- candlepin
- httpd
- pulp
Expand Down
2 changes: 1 addition & 1 deletion src/playbooks/pull-images/pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- foreman
- candlepin
- pulp
- redis
- valkey

- name: Deploy database image units
ansible.builtin.include_role:
Expand Down
4 changes: 2 additions & 2 deletions src/roles/candlepin/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
Wants=redis.service postgresql.service
After=redis.service postgresql.service
Wants=valkey.service postgresql.service
After=valkey.service postgresql.service
[Service]
TimeoutStartSec=300
healthcheck: curl --fail --insecure https://localhost:23443/candlepin/status
Expand Down
8 changes: 4 additions & 4 deletions src/roles/foreman/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
Wants=redis.service postgresql.service candlepin.service
After=redis.service postgresql.service candlepin.service
Wants=valkey.service postgresql.service candlepin.service
After=valkey.service postgresql.service candlepin.service
Requires=foreman-db-migrate.service
After=foreman-db-migrate.service
notify: Restart foreman
Expand Down Expand Up @@ -172,8 +172,8 @@
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
Wants=redis.service postgresql.service
After=redis.service postgresql.service
Wants=valkey.service postgresql.service
After=valkey.service postgresql.service
Requires=foreman-db-migrate.service
After=foreman-db-migrate.service
- |
Expand Down
12 changes: 6 additions & 6 deletions src/roles/pulp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
Wants=redis.service postgresql.service
After=redis.service postgresql.service
Wants=valkey.service postgresql.service
After=valkey.service postgresql.service
[Service]
Restart=always
RestartSec=3
Expand Down Expand Up @@ -145,8 +145,8 @@
WantedBy=default.target foreman.target
[Unit]
PartOf=foreman.target
Wants=redis.service postgresql.service
After=redis.service postgresql.service
Wants=valkey.service postgresql.service
After=valkey.service postgresql.service
[Service]
Restart=always
RestartSec=3
Expand Down Expand Up @@ -176,8 +176,8 @@
WantedBy=foreman.target pulp-worker.target
[Unit]
PartOf=pulp-worker.target foreman.target
Wants=redis.service postgresql.service
After=redis.service postgresql.service
Wants=valkey.service postgresql.service
After=valkey.service postgresql.service
[Service]
Restart=always
RestartSec=3
Expand Down
3 changes: 0 additions & 3 deletions src/roles/redis/defaults/main.yml

This file was deleted.

9 changes: 0 additions & 9 deletions src/roles/redis/tasks/image.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions src/roles/valkey/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
valkey_container_image: quay.io/sclorg/valkey-8-c10s
valkey_container_tag: "latest"
36 changes: 36 additions & 0 deletions src/roles/valkey/tasks/cleanup_redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
Comment thread
shubhamsg199 marked this conversation as resolved.
Resolved
- name: Populate service facts
ansible.builtin.service_facts:

- name: Stop Redis service
ansible.builtin.service:
name: redis
state: stopped
when: ansible_facts['services']['redis.service']['status'] | default('not-found') != 'not-found'
Comment thread
Gauravtalreja1 marked this conversation as resolved.
Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Claude, we should rely on existence of redis.service under services. It says that the status field may not be there. Didn't check it further myself, so I would accept it's not correct if you say so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no friends called Claude.

I do however have access to the Ansible documentation, where this exact line is used in an example how to do it: https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/service_facts_module.html#examples


- name: Remove Redis package

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, this means we assume Redis package is installed directly on the host. In which scenario it would be installed? I was under the impression that it should be only installed as a container.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For upgrades from RPM-based installations, it will be a package.
Not necessary today, but will be in the future, and typing it out already was cheap enough.

ansible.builtin.package:
name: redis
state: absent

- name: Remove Redis image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the ready-made image module from Ansible instead of chasing the services e.t.c.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware that this module can remove quadlet definitions (which is what we're removing here). But if you have an example how it can be done: yes, that'd be cleaner then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Remove an image
  containers.podman.podman_image:
    name: quay.io/bitnami/wildfly
    state: absent

From the example. I suppose it would be a follow-up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which removes an image, not an image definition (which is what we're removing here).

# cat t.yaml 
---
- hosts: localhost
  tasks:
  - name: Generate image file
    containers.podman.podman_image:
      name: "quay.io/bitnami/wildfly"
      state: quadlet
      quadlet_filename: "wildfly"

  - name: Delete image definition
    containers.podman.podman_image:
      name: "quay.io/bitnami/wildfly"
      state: absent
      quadlet_filename: "wildfly"

# ansible-playbook t.yaml 
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] 

TASK [Gathering Facts] 
ok: [localhost]

TASK [Generate image file] 
changed: [localhost]

TASK [Delete image definition] 
ok: [localhost]

PLAY RECAP 
localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

# ls -alh /etc/containers/systemd/
total 12K
drwxr-xr-x. 2 root root 4.0K Jun 29 08:14 .
drwxr-xr-x. 7 root root 4.0K Jun 29 08:12 ..
-rw-r-----. 1 root root   38 Jun 29 08:14 wildfly.image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just reading the podman module source...
Apparently the podman_quadlet module should remove all the leftovers (at least in some cases): https://github.com/containers/ansible-podman-collections/blob/efa337c5362f8603d4e1b105fc2d89d894bdd8fe/plugins/modules/podman_quadlet.py#L720
Still trying to understand how to properly use the module though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think using podman_quadlet might be a way for this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansible.builtin.file:
path: /etc/containers/systemd/redis.image
state: absent

- name: Remove Redis image drop-in directory
ansible.builtin.file:
path: /etc/containers/systemd/redis.image.d
state: absent

- name: Remove Redis container
ansible.builtin.file:
path: /etc/containers/systemd/redis.container
Comment thread
Gauravtalreja1 marked this conversation as resolved.
Resolved
state: absent
register: _valkey_remove_redis_container

- name: Run daemon reload # noqa: no-handler
ansible.builtin.systemd:
daemon_reload: true
when:
- _valkey_remove_redis_container is changed
9 changes: 9 additions & 0 deletions src/roles/valkey/tasks/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Deploy valkey image unit
ansible.builtin.include_role:
name: images
tasks_from: deploy_image.yaml
vars:
images_definition:
name: valkey
image: "{{ valkey_container_image }}:{{ valkey_container_tag }}"
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
---
- name: Deploy redis image
- name: Deploy valkey image
ansible.builtin.include_tasks: image.yaml

- name: Create directory for Redis data
- name: Cleanup Redis
ansible.builtin.include_tasks: cleanup_redis.yaml

- name: Create directory for Valkey data
ansible.builtin.file:
path: /var/lib/redis
path: /var/lib/valkey
state: directory
owner: 1001
group: 1001
mode: '0755'

- name: Run Redis as a container
- name: Run Valkey as a container
containers.podman.podman_container:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we consider using the podman_quadlet module? It has much less options, so I am not sure it will do the trick here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't, as that module didn't exist when we originally written this code. It's worth investigating whether we should switch the whole codebase to it. But not in this PR which merely renames Redis→Valkey.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name: redis
image: redis.image
name: valkey
image: valkey.image
state: quadlet
network: host
sdnotify: true
command: ["run-redis", "--supervised", "systemd"]
command: ["run-valkey", "--supervised", "systemd"]
volumes:
- /var/lib/redis:/data:rw,Z
- /var/lib/valkey:/data:rw,Z

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes we don't need data migration. Seems OK to me, but just want to confirm.

Also I suppose we can delete the old folder, if we don't use it anymore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the data is not valuable: #582 (review)

And yes, we could delete the old folder in cleanup_redis.

quadlet_options:
- |
[Install]
Expand All @@ -31,7 +34,7 @@
ansible.builtin.systemd:
daemon_reload: true

- name: Start the Redis Service
- name: Start the Valkey Service
ansible.builtin.systemd:
name: redis
name: valkey
state: started
4 changes: 2 additions & 2 deletions src/vars/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ postgresql_container_image: quay.io/sclorg/postgresql-13-c9s
postgresql_container_tag: "latest"
pulp_container_image: quay.io/foreman/pulp
pulp_container_tag: "foreman-{{ container_tag_stream }}"
redis_container_image: quay.io/sclorg/redis-6-c9s
redis_container_tag: "latest"
valkey_container_image: quay.io/sclorg/valkey-8-c10s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to specify the image twice? There is also mention of the image in valkey/defaults/main.yaml

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the role can work standalone, while this file being the canonical source of truth for the foremanctl-based deployment.

valkey_container_tag: "latest"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this means we're OK with whatever comes into RHEL 10?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before. yes.

2 changes: 1 addition & 1 deletion tests/images_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"foreman",
"candlepin",
"pulp",
"redis",
"valkey",
]


Expand Down
12 changes: 0 additions & 12 deletions tests/redis_test.py

This file was deleted.

12 changes: 12 additions & 0 deletions tests/valkey_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VALKEY_HOST = 'localhost'
VALKEY_PORT = 6379


def test_valkey_service(server):
valkey = server.service("valkey")
assert valkey.is_running


def test_valkey_port(server):
valkey = server.addr(VALKEY_HOST)
assert valkey.port(VALKEY_PORT).is_reachable