Skip to content

Commit

Permalink
Postgresql service
Browse files Browse the repository at this point in the history
Signed-off-by: desmax74 <[email protected]>
  • Loading branch information
desmax74 committed Sep 2, 2024
1 parent 95e205e commit 613ccce
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/molecule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# ansible-galaxy install -r molecule/requirements.yml
# - name: Image mirroring
# run: |
# sed -f vm-testing/dev-images.sed -i roles/tas_single_node/defaults/main.yml
# sed -f vm-testing/dev-images.sed -i roles/tpa_single_node/defaults/main.yml
# - name: Run molecule
# env:
# TPA_SINGLE_NODE_REGISTRY_USERNAME: ${{ secrets.TPA_SINGLE_NODE_REGISTRY_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion molecule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ source venv/bin/activate
pip3 install -r requirements-testing.txt
ansible-galaxy install -r requirements.yml
ansible-galaxy install -r molecule/requirements.yml
sed -f vm-testing/dev-images.sed -i roles/tas_single_node/defaults/main.yml
sed -f vm-testing/dev-images.sed -i roles/tpa__single_node/defaults/main.yml
```

Next, export following values in your shell environment:
Expand Down
3 changes: 2 additions & 1 deletion play.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
tpa_single_node_base_hostname: trustification
tpa_single_node_skip_os_install: true
tpa_single_node_config_dir: /etc/rhtpa
tpa_single_node_systemd_directory: /etc/systemd/system
tpa_single_node_certs_dir: "{{ tpa_single_node_config_dir }}/certs"
tpa_single_node_kube_manifest_dir: "{{ tpa_single_node_config_dir }}/manifests"
tpa_single_node_kube_configmap_dir: "{{ tpa_single_node_config_dir }}/configs"
tpa_single_node_kube_manifest_dir: "{{ tpa_single_node_config_dir }}/manifests"
# * tpa_single_node_registry_username
# * get at https://access.redhat.com/terms-based-registry
tpa_single_node_registry_username: <your Red Hat username>
Expand Down
12 changes: 12 additions & 0 deletions roles/tpa_single_node/tasks/podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
register: podman_login_result
changed_when: '"Already logged in" not in podman_login_result'

- name: Create Manifests/Configs Directory
ansible.builtin.file:
state: directory
dest: "{{ item }}"
mode: "0700"
loop:
- "{{ tpa_single_node_kube_manifest_dir }}"
- "{{ tpa_single_node_kube_configmap_dir }}"

- name: Create RHTPA network
containers.podman.podman_network:
name: "{{ tpa_single_node_podman_network }}"
Expand Down Expand Up @@ -55,5 +64,8 @@
containers.podman.podman_image:
name: "{{ tpa_single_node_s3 }}"

- name: Configure/Postgresql DB
ansible.builtin.include_tasks: podman/postgresql.yml

- name: Configure/Deploy guac
ansible.builtin.include_tasks: podman/guac.yml
25 changes: 25 additions & 0 deletions roles/tpa_single_node/tasks/podman/postgresql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Confirmed required parameters provided
ansible.builtin.assert:
that:
- tpa_single_node_base_hostname is defined
- tpa_single_node_base_hostname | trim | length > 0
msg: "'tpa_single_node_base_hostname' must be specified"

- name: Get RHTPA network details
containers.podman.podman_network:
name: "{{ tpa_single_node_podman_network }}"
register: tpa_podman_network_results

- name: Set DNS Resolver
ansible.builtin.set_fact:
dns_resolver: "{{ tpa_podman_network_results.network.subnets[0].gateway }}"

- name: Deploy postgresql Pod
ansible.builtin.include_tasks: podman/install_manifest.yml
vars:
podman_spec:
state: started
network: "{{ tpa_single_node_podman_network }}"
systemd_file: postgresql
kube_file_content: "{{ lookup('ansible.builtin.template', 'manifests/postgresql/postgresql.yml') | from_yaml }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Pod
metadata:
labels:
app: rhtpa
name: rhtpa
namespace: trustification
spec:
containers:
- image: "{{ tpa_single_node_postgresql }}"
name: db
env:
- name: POSTGRES_USER
value: "guac"
- name: POSTGRES_PASSWORD
value: "guac1234"
- name: POSTGRES_DB
value: "postgres"
ports:
- containerPort: 5432
hostPort: 5432
name: postgresql
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data

0 comments on commit 613ccce

Please sign in to comment.