Skip to content

Commit 2f42b8a

Browse files
authored
Merge pull request #3909 from priti-parate/pub/build_stream
update postgres service name and pull image from dockerhub
2 parents c98e82f + d52ed2b commit 2f42b8a

File tree

10 files changed

+278
-82
lines changed

10 files changed

+278
-82
lines changed

prepare_oim/roles/deploy_containers/build_stream/tasks/deploy_build_stream.yml

Lines changed: 130 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -118,86 +118,147 @@
118118
mode: "{{ build_stream_dir_mode }}"
119119

120120
# -------------------------------------------------------------------
121-
# 4) Deploy quadlet using template + restart via handlers
121+
# 4) Pull container image
122122
# -------------------------------------------------------------------
123-
- name: Ensure quadlet directory exists
123+
- name: Pull omnia_build_stream image from Docker Hub
124+
containers.podman.podman_image:
125+
name: "{{ build_stream_image_name }}"
126+
tag: "{{ build_stream_image_tag }}"
127+
state: present
128+
register: image_pull_result
129+
130+
- name: Display image pull result
131+
ansible.builtin.debug:
132+
msg: "{{ build_stream_image_pull_success_msg }}"
133+
verbosity: 2
134+
when: image_pull_result is succeeded
135+
136+
# Generate SSL certificates
137+
- name: Check if SSL certificates already exist
138+
ansible.builtin.stat:
139+
path: "{{ build_stream_ssl_cert }}"
140+
register: ssl_cert_stat
141+
142+
- name: Create SSL certificate directory
124143
ansible.builtin.file:
125-
path: "{{ quadlet_dir }}"
144+
path: "{{ build_stream_ssl_dir }}"
126145
state: directory
127146
mode: "{{ build_stream_dir_mode }}"
147+
when: not ssl_cert_stat.stat.exists
128148

129-
- name: Deploy build_stream quadlet file from template
130-
ansible.builtin.template:
131-
src: "build_stream.j2"
132-
dest: "{{ build_stream_quadlet_path }}"
133-
mode: "{{ build_stream_quadlet_file_mode }}"
134-
notify:
135-
- Reload systemd
136-
- Restart build_stream
149+
- name: Generate self-signed SSL certificate
150+
ansible.builtin.command: |
151+
openssl req -x509 -newkey rsa:4096 -nodes -days {{ build_stream_ssl_days }}
152+
-keyout {{ build_stream_ssl_key }}
153+
-out {{ build_stream_ssl_cert }}
154+
-subj "/C=US/ST=State/L=City/O=Omnia/CN={{ ansible_hostname }}"
155+
-addext "subjectAltName=DNS:{{ ansible_hostname }},DNS:localhost,IP:{{ ansible_default_ipv4.address }}"
156+
when: not ssl_cert_stat.stat.exists
157+
changed_when: true
137158

138-
- name: Enable and start build_stream service
139-
ansible.builtin.systemd_service:
140-
name: "{{ build_stream_service }}"
141-
enabled: true
142-
state: started
159+
- name: Set permissions on SSL certificates
160+
ansible.builtin.file:
161+
path: "{{ item }}"
162+
mode: "{{ build_stream_ssl_file_mode }}"
163+
loop:
164+
- "{{ build_stream_ssl_cert }}"
165+
- "{{ build_stream_ssl_key }}"
166+
# -------------------------------------------------------------------
167+
# 4) Deploy quadlet using template + restart via handlers
168+
# -------------------------------------------------------------------
169+
- name: Deploy build_stream container and check deployment status
170+
block:
171+
- name: Ensure quadlet directory exists
172+
ansible.builtin.file:
173+
path: "{{ quadlet_dir }}"
174+
state: directory
175+
mode: "{{ build_stream_dir_mode }}"
143176

144-
# Ensure restart happens before validation
145-
- name: Apply systemd reload/restart now
146-
ansible.builtin.meta: flush_handlers
177+
- name: Create Quadlet service file
178+
ansible.builtin.template:
179+
src: build_stream.j2
180+
dest: "{{ build_stream_quadlet_path }}"
181+
mode: "{{ build_stream_quadlet_file_mode }}"
182+
register: quadlet_out
183+
notify:
184+
- Reload systemd
147185

148-
- name: Wait until omnia_build_stream container exists and is running
149-
containers.podman.podman_container_info:
150-
name: "{{ build_stream_container_name }}"
151-
register: bs_info
152-
retries: "{{ bs_container_wait_retries }}"
153-
delay: "{{ bs_container_wait_delay }}"
154-
until:
155-
- bs_info.containers is defined
156-
- bs_info.containers | length > 0
157-
- bs_info.containers[0].State is defined
158-
- bs_info.containers[0].State.Running | bool
186+
- name: Deploy build_stream quadlet file from template
187+
ansible.builtin.template:
188+
src: "build_stream.j2"
189+
dest: "{{ build_stream_quadlet_path }}"
190+
mode: "{{ build_stream_quadlet_file_mode }}"
191+
notify:
192+
- Reload systemd
193+
- Restart build_stream
159194

160-
# -------------------------------------------------------------------
161-
# 5) Validate HTTPS connectivity from inside build_stream
162-
# -------------------------------------------------------------------
163-
- name: Build curl command
164-
ansible.builtin.set_fact:
165-
curl_cmd:
166-
- curl
167-
- -sS
168-
- -o
169-
- /dev/null
170-
- -w
171-
- "%{http_code}\n"
172-
- --cacert
173-
- "{{ build_stream_pulp_cert_container_path }}"
174-
- "{{ pulp_base_url }}/pulp/api/v3/status/"
175-
changed_when: false
195+
- name: Enable and start build_stream service
196+
ansible.builtin.systemd_service:
197+
name: "{{ build_stream_service }}"
198+
enabled: true
199+
state: started
176200

177-
- name: Test HTTPS from build_stream to Pulp (exec)
178-
containers.podman.podman_container_exec:
179-
name: "{{ build_stream_container_name }}"
180-
argv: "{{ curl_cmd }}"
181-
register: curl_status
182-
changed_when: false
183-
failed_when: false
201+
# Ensure restart happens before validation
202+
- name: Apply systemd reload/restart now
203+
ansible.builtin.meta: flush_handlers
204+
205+
- name: Wait until omnia_build_stream container exists and is running
206+
containers.podman.podman_container_info:
207+
name: "{{ build_stream_container_name }}"
208+
register: bs_info
209+
retries: "{{ bs_container_wait_retries }}"
210+
delay: "{{ bs_container_wait_delay }}"
211+
until:
212+
- bs_info.containers is defined
213+
- bs_info.containers | length > 0
214+
- bs_info.containers[0].State is defined
215+
- bs_info.containers[0].State.Running | bool
184216

185-
- name: Fail if HTTPS test is not 200
186-
ansible.builtin.fail:
187-
msg: "{{ build_stream_https_failure_msg }}"
188-
when: (curl_status.stdout | trim) != "200"
217+
# -------------------------------------------------------------------
218+
# 5) Validate HTTPS connectivity from inside build_stream
219+
# -------------------------------------------------------------------
220+
- name: Build curl command
221+
ansible.builtin.set_fact:
222+
curl_cmd:
223+
- curl
224+
- -sS
225+
- -o
226+
- /dev/null
227+
- -w
228+
- "%{http_code}\n"
229+
- --cacert
230+
- "{{ build_stream_pulp_cert_container_path }}"
231+
- "{{ pulp_base_url }}/pulp/api/v3/status/"
232+
changed_when: false
189233

190-
# -------------------------------------------------------------------
234+
- name: Test HTTPS from build_stream to Pulp
235+
containers.podman.podman_container_exec:
236+
name: "{{ build_stream_container_name }}"
237+
argv: "{{ curl_cmd }}"
238+
register: curl_status
239+
changed_when: false
240+
failed_when: false
241+
242+
- name: Fail if HTTPS test is not 200
243+
ansible.builtin.fail:
244+
msg: "{{ build_stream_https_failure_msg }}"
245+
when: (curl_status.stdout | trim) != "200"
246+
# --------------------------------------------------------------------
191247
# 6) Validate health API endpoint https://localhost:{{ build_stream_port }}/health"
192248
# -------------------------------------------------------------------
193-
- name: Wait until omnia_build_stream container exists and is running
194-
containers.podman.podman_container_info:
195-
name: "{{ build_stream_container_name }}"
196-
register: bs_info
197-
retries: "{{ bs_container_wait_retries }}"
198-
delay: "{{ bs_container_wait_delay }}"
199-
until:
200-
- bs_info.containers is defined
201-
- bs_info.containers | length > 0
202-
- bs_info.containers[0].State is defined
203-
- bs_info.containers[0].State.Running | bool
249+
- name: Wait until omnia_build_stream container exists and is running
250+
containers.podman.podman_container_info:
251+
name: "{{ build_stream_container_name }}"
252+
register: bs_info
253+
retries: "{{ bs_container_wait_retries }}"
254+
delay: "{{ bs_container_wait_delay }}"
255+
until:
256+
- bs_info.containers is defined
257+
- bs_info.containers | length > 0
258+
- bs_info.containers[0].State is defined
259+
- bs_info.containers[0].State.Running | bool
260+
261+
rescue:
262+
- name: Build_stream container deployment failed
263+
ansible.builtin.fail:
264+
msg: "{{ build_stream_container_failure_msg }}"

prepare_oim/roles/deploy_containers/build_stream/vars/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ build_stream_quadlet_file_mode: "0644"
7777
# PostgreSQL configuration (from postgres role)
7878
postgres_user: "{{ hostvars['localhost']['postgres_user'] }}"
7979
postgres_password: "{{ hostvars['localhost']['postgres_password'] }}"
80-
postgres_db_name: "build_stream"
80+
postgres_db_name: "{{ hostvars['localhost']['postgres_db_name'] | default('build_stream_db') }}"
8181

8282
###############################################################
8383
###############################################################
@@ -104,6 +104,15 @@ build_stream_firewall_port: "{{ build_stream_port }}/tcp"
104104
###############################################################
105105
# User messages
106106
###############################################################
107+
build_stream_image_pull_success_msg:
108+
- "Successfully pulled image from Docker Hub"
109+
- "Image: {{ build_stream_image_name }}:{{ build_stream_image_tag }}"
110+
111+
build_stream_container_failure_msg: |
112+
The deployment of the {{ build_stream_container_name }} container has failed. To resolve this issue,
113+
please run the utility/oim_cleanup.yml playbook to clean up any existing OIM resources.
114+
After the cleanup, you can re-run the original playbook to deploy the {{ build_stream_container_name }} container successfully.
115+
107116
build_stream_pulp_not_ready_msg: |
108117
Pulp container '{{ pulp_container_name }}' is not ready.
109118
Exists={{ (pulp_container_info.containers | length) > 0 }},

prepare_oim/roles/deploy_containers/postgres/tasks/deploy_postgres.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515
---
1616

1717
# Check and remove existing postgres container if running
18-
- name: Check if build_stream_postgres service exists
18+
- name: Check if omnia_postgres service exists
1919
ansible.builtin.systemd:
2020
name: "{{ postgres_container_name }}.service"
2121
register: postgres_service_status
2222
failed_when: false
2323

24-
- name: Stop build_stream_postgres service if running
24+
- name: Stop omnia_postgres service if running
2525
ansible.builtin.systemd:
2626
name: "{{ postgres_container_name }}.service"
2727
state: stopped
2828
enabled: false
2929
when: postgres_service_status.status is defined
3030
failed_when: false
3131

32-
- name: Check if build_stream_postgres container exists
32+
- name: Check if omnia_postgres container exists
3333
containers.podman.podman_container_info:
3434
name: "{{ postgres_container_name }}"
3535
register: existing_container_info
3636
failed_when: false
3737

38-
- name: Remove existing build_stream_postgres container
38+
- name: Remove existing omnia_postgres container
3939
containers.podman.podman_container:
4040
name: "{{ postgres_container_name }}"
4141
state: absent
@@ -60,20 +60,20 @@
6060
selinux_option: "{{ ':z' if (share_option != 'NFS' or nfs_type | default('') != 'external') else '' }}"
6161

6262
# Create required directories
63-
- name: Create data directory for build_stream_postgres
63+
- name: Create data directory for omnia_postgres
6464
ansible.builtin.file:
6565
path: "{{ postgres_data_dir }}"
6666
state: directory
6767
mode: "{{ postgres_dir_mode }}"
6868

69-
- name: Create log directory for build_stream_postgres
69+
- name: Create log directory for omnia_postgres
7070
ansible.builtin.file:
7171
path: "{{ postgres_log_dir }}"
7272
state: directory
7373
mode: "{{ postgres_dir_mode }}"
7474

7575
# Pull container image
76-
- name: Pull build_stream_postgres image from Docker Hub
76+
- name: Pull omnia_postgres image from Docker Hub
7777
containers.podman.podman_image:
7878
name: "{{ postgres_image }}"
7979
tag: "{{ postgres_image_tag }}"

prepare_oim/roles/deploy_containers/postgres/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
---
1616

17-
- name: Deploy build_stream_postgres container
17+
- name: Deploy omnia_postgres container
1818
ansible.builtin.include_tasks: deploy_postgres.yml
1919
tags:
2020
- postgres

prepare_oim/roles/deploy_containers/postgres/templates/postgres.j2

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
# Copyright 2026 Dell Inc. or its subsidiaries. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
# ===============================================================
2-
# build_stream_postgres Quadlet Service
16+
# omnia_postgres Quadlet Service
317
# PostgreSQL Database for Omnia BuildStream
418
# ===============================================================
519
[Unit]

prepare_oim/roles/deploy_containers/postgres/vars/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
---
1616

1717
# PostgreSQL Container Configuration
18-
postgres_container_name: "build_stream_postgres"
18+
postgres_container_name: "omnia_postgres"
1919

2020
# OIM metadata file path
2121
oim_metadata_file: "/opt/omnia/.data/oim_metadata.yml"
@@ -29,7 +29,7 @@ postgres_port: 5432
2929
# Database configuration
3030
postgres_user: "{{ hostvars['localhost']['postgres_user'] }}"
3131
postgres_password: "{{ hostvars['localhost']['postgres_password'] }}"
32-
postgres_db_name: "build_stream"
32+
postgres_db_name: "{{ hostvars['localhost']['postgres_db_name'] | default('build_stream_db') }}"
3333

3434
# Storage configuration
3535
postgres_data_dir: "{{ omnia_path }}/postgres/data"

utils/roles/oim_cleanup/oim_container_cleanup/tasks/cleanup_build_stream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
- name: Get omnia_build_stream container files
3636
ansible.builtin.find:
37-
paths: "/etc/containers/systemd/"
37+
paths: "{{ quadlet_dir }}"
3838
patterns: 'omnia_build_stream*'
3939
file_type: file
4040
register: found_files

0 commit comments

Comments
 (0)