Skip to content

Commit

Permalink
add reader
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Sep 25, 2019
1 parent b1563ad commit 619aea9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -22,6 +22,7 @@ metadata:
type: Opaque
stringData:
mariadb_hostname: db.maria.com
mariadb_reader_hostname: db.reader.maria.com
mariadb_password: myPassword
mariadb_port: '3306'
mariadb_user: root
Expand All @@ -34,6 +35,7 @@ metadata:
type: Opaque
stringData:
mariadb_hostname: db.maria.com
mariadb_reader_hostname: db.reader.maria.com
mariadb_password: myPassword
mariadb_port: '3306'
mariadb_user: root
Expand Down Expand Up @@ -62,3 +64,6 @@ Install the [APB CLI](https://github.com/ansibleplaybookbundle/ansible-playbook-

## Release
An automatic Docker build is set up for this repository. If you change stuff in `apb.yml` don't forget to run `apb prepare` before committing.

## Reader configuration
If the mariadb/mysql supports a reader instance aswell as a writer, you can configure the `mariadb_reader_hostname` to point to the endpoint for a reader, otherwise just populate it with the same value as the `mariadb_hostname` if one is not available
1 change: 1 addition & 0 deletions defaults/main.yml
Expand Up @@ -6,3 +6,4 @@ _apb_service_class_id: 0
_apb_service_instance_id: 0

app_name: "mariadb-{{ _apb_service_instance_id }}"
app_reader_name: "mariadb-reader-{{ _apb_service_instance_id }}"
10 changes: 10 additions & 0 deletions tasks/main.yml
Expand Up @@ -13,6 +13,7 @@
- name: read DB credentials
set_fact:
mariadb_hostname: "{{ lookup('file', secret ~ '_mariadb_hostname') }}"
mariadb_reader_hostname: "{{ lookup('file', secret ~ '_mariadb_reader_hostname') }}"
mariadb_port: "{{ lookup('file', secret ~ '_mariadb_port') }}"
mariadb_user: "{{ lookup('file', secret ~ '_mariadb_user') }}"
mariadb_password: "{{ lookup('file', secret ~ '_mariadb_password') }}"
Expand All @@ -30,6 +31,7 @@
DB_TYPE: "{{ 'mariadb' }}"
DB_NAME: "{{ create_db_name }}"
DB_HOST: "{{ app_name }}"
DB_READER_HOST: "{{ app_reader_name }}"
DB_PORT: "{{ mariadb_port }}"
DB_USER: "{{ create_db_user }}"
DB_PASSWORD: "{{ create_db_password }}"
Expand Down Expand Up @@ -80,6 +82,14 @@
type: ExternalName
external_name: "{{ mariadb_hostname }}"

- name: "{{ apb_action }} OpenShift service"
k8s_v1_service:
state: "{{ ensure_state }}"
name: "{{ app_reader_name }}"
namespace: "{{ namespace }}"
type: ExternalName
external_name: "{{ mariadb_reader_hostname }}"

- name: "{{ apb_action }} secret with DB credentials"
k8s:
state: "{{ ensure_state }}"
Expand Down

0 comments on commit 619aea9

Please sign in to comment.