From 8f2f6582067f7c3e25fd94b8394b30b923a3d786 Mon Sep 17 00:00:00 2001 From: lrossett Date: Jun 17 2021 17:33:41 +0000 Subject: var name fix --- diff --git a/playbooks/openshift-apps/resultsdb.yml b/playbooks/openshift-apps/resultsdb.yml index b208ca3..e1b4635 100644 --- a/playbooks/openshift-apps/resultsdb.yml +++ b/playbooks/openshift-apps/resultsdb.yml @@ -5,26 +5,26 @@ become: yes become_user: postgres vars_files: - - /srv/web/infra/ansible/vars/global.yml - - /srv/private/ansible/vars.yml - - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml + - /srv/web/infra/ansible/vars/global.yml + - /srv/private/ansible/vars.yml + - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml tasks: - - name: resultsdb DB user - prod - postgresql_user: - name: "resultsdb" - password: "{{ prod_resultsdb_db_password }}" - when: env != 'staging' - - name: resultsdb DB user - staging - postgresql_user: - name: "resultsdb" - password: "{{ stg_resultsdb_db_password }}" - when: env == 'staging' - - name: resultsdb database creation - postgresql_db: - name: "resultsdb" - owner: "resultsdb" - encoding: UTF-8 + - name: resultsdb DB user - prod + postgresql_user: + name: "resultsdb" + password: "{{ prod_resultsdb_db_password }}" + when: env != 'staging' + - name: resultsdb DB user - staging + postgresql_user: + name: "resultsdb" + password: "{{ stg_resultsdb_db_password }}" + when: env == 'staging' + - name: resultsdb database creation + postgresql_db: + name: "resultsdb" + owner: "resultsdb" + encoding: UTF-8 - name: make the app be real @@ -35,9 +35,8 @@ vars_files: - /srv/web/infra/ansible/vars/global.yml - - "/srv/private/ansible/vars.yml" + - /srv/private/ansible/vars.yml - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml - # TODO: change to vars/{{ env }}.yml - /srv/web/infra/ansible/roles/openshift-apps/resultsdb/vars/main.yml roles: @@ -58,6 +57,7 @@ - pingou - lholecek - vmaljulin + - lrossett tags: - apply-appowners @@ -91,6 +91,11 @@ - role: openshift/object app: resultsdb + template: deploymentconfigs.yml + objectname: deploymentconfigs.yml + + - role: openshift/object + app: resultsdb template: services.yml objectname: services.yml @@ -101,11 +106,6 @@ serviceport: api servicename: resultsdb-web - - role: openshift/object - app: resultsdb - template: deploymentconfigs.yml - objectname: deploymentconfigs.yml - - role: openshift/rollout app: resultsdb - dcname: "resultsdb-test-{{ resultsdb_test_id }}-api" \ No newline at end of file + dcname: "resultsdb-api" \ No newline at end of file diff --git a/roles/openshift-apps/resultsdb/templates/configmaps.yml b/roles/openshift-apps/resultsdb/templates/configmaps.yml index 6dd792a..8780af7 100644 --- a/roles/openshift-apps/resultsdb/templates/configmaps.yml +++ b/roles/openshift-apps/resultsdb/templates/configmaps.yml @@ -1,9 +1,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: "resultsdb-test-{{ resultsdb_test_id }}-httpd-config" + name: "resultsdb-httpd-config" labels: - environment: "test-{{ resultsdb_test_id }}" app: resultsdb data: resultsdb.conf: |- @@ -27,6 +26,7 @@ data: --- +{% if deployment_type not in ['local', 'dev']%} apiVersion: v1 kind: ConfigMap metadata: @@ -47,3 +47,4 @@ data: ca_cert = "/etc/pki/rabbitmq/ca/resultsdb.ca" keyfile = "/etc/pki/rabbitmq/key/resultsdb.key" certfile = "/etc/pki/rabbitmq/crt/resultsdb.crt" +{% endif %} \ No newline at end of file diff --git a/roles/openshift-apps/resultsdb/templates/deploymentconfigs.yml b/roles/openshift-apps/resultsdb/templates/deploymentconfigs.yml index 5c7bd65..07f407f 100644 --- a/roles/openshift-apps/resultsdb/templates/deploymentconfigs.yml +++ b/roles/openshift-apps/resultsdb/templates/deploymentconfigs.yml @@ -1,16 +1,14 @@ apiVersion: v1 kind: DeploymentConfig metadata: - name: "resultsdb-test-{{ resultsdb_test_id }}-api" + name: "resultsdb-api" labels: - environment: "test-{{ resultsdb_test_id }}" service: api app: resultsdb spec: replicas: 2 selector: app: resultsdb - environment: "test-{{ resultsdb_test_id }}" service: api strategy: type: Rolling @@ -40,13 +38,16 @@ spec: template: metadata: labels: - environment: "test-{{ resultsdb_test_id }}" service: api app: resultsdb spec: containers: - name: api - image: "{{ resultsdb_image }}" +{% if env == 'staging' %} + image: "{{ stg_resultsdb_image }}" +{% else %} + image: "{{ prod_resultsdb_image }}" +{% endif %} imagePullPolicy: Always ports: - containerPort: 5001 @@ -91,10 +92,10 @@ spec: volumes: - name: config-volume secret: - secretName: "resultsdb-test-{{ resultsdb_test_id }}-config" + secretName: "resultsdb-config" - name: httpd-config-volume configMap: - name: "resultsdb-test-{{ resultsdb_test_id }}-httpd-config" + name: "resultsdb-httpd-config" - name: fedora-messaging-config-volume configMap: name: fedora-messaging-configmap diff --git a/roles/openshift-apps/resultsdb/templates/routes.yml b/roles/openshift-apps/resultsdb/templates/routes.yml index f66d28c..ff2e8ed 100644 --- a/roles/openshift-apps/resultsdb/templates/routes.yml +++ b/roles/openshift-apps/resultsdb/templates/routes.yml @@ -1,16 +1,15 @@ apiVersion: v1 kind: Route metadata: - name: "resultsdb-test-{{ resultsdb_test_id }}-api" + name: "resultsdb-test-api" labels: - environment: "test-{{ resultsdb_test_id }}" app: resultsdb spec: port: targetPort: api to: kind: Service - name: "resultsdb-test-{{ resultsdb_test_id }}-api" + name: "resultsdb-api" tls: termination: edge insecureEdgeTerminationPolicy: Redirect \ No newline at end of file diff --git a/roles/openshift-apps/resultsdb/templates/secrets.yml b/roles/openshift-apps/resultsdb/templates/secrets.yml index fe155dd..dbbf9d1 100644 --- a/roles/openshift-apps/resultsdb/templates/secrets.yml +++ b/roles/openshift-apps/resultsdb/templates/secrets.yml @@ -1,24 +1,44 @@ apiVersion: v1 kind: Secret metadata: - name: "resultsdb-test-{{ resultsdb_test_id }}-config" + name: "resultsdb-config" labels: - environment: "test-{{ resultsdb_test_id }}" app: resultsdb stringData: settings.py: |- - SECRET_KEY = '{{ resultsdb_secret_key }}' - SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://resultsdb:{{ resultsdb_db_password }}@resultsdb-test-{{ resultsdb_test_id }}-database:5432/resultsdb' +{% if env == 'staging' %} + SECRET_KEY = '{{ stg_resultsdb_secret_key }}' +{% else %} + SECRET_KEY = '{{ prod_resultsdb_secret_key }}' +{% endif %} +{% if env == 'staging' %} + SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://{{ stg_resultsdb_db_user }}:{{ stg_resultsdb_db_password }}@{{ stg_resultsdb_db_host }}:{{ stg_resultsdb_db_port }}/{{ stg_resultsdb_db_name }}' +{% else %} + SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://{{ prod_resultsdb_db_user }}:{{ prod_resultsdb_db_password }}@{{ prod_resultsdb_db_host }}:{{ prod_resultsdb_db_port }}/{{ prod_resultsdb_db_name }}' +{% endif %} FILE_LOGGING = False LOGFILE = '/var/log/resultsdb/resultsdb.log' SYSLOG_LOGGING = False STREAM_LOGGING = True RUN_HOST= '0.0.0.0' RUN_PORT = 5001 - MESSAGE_BUS_PUBLISH = {{ resultsdb_publish | bool }} +{% if deployment_type in ['local', 'dev']%} + MESSAGE_BUS_PUBLISH = False + MESSAGE_BUS_PUBLISH_TASKOTRON = False +{% else %} + MESSAGE_BUS_PUBLISH = True + MESSAGE_BUS_PUBLISH_TASKOTRON = True +{% endif %} MESSAGE_BUS_PLUGIN = 'fedmsg' +{% if deployment_type in ['local'] %} + # This is for the Testdays deployment + MESSAGE_BUS_PLUGIN = 'dummy' +{% endif %} MESSAGE_BUS_KWARGS = {'modname': 'resultsdb'} ADDITIONAL_RESULT_OUTCOMES = {{ resultsdb_additional_result_outcomes }} - # Credentials are resultsdb-updater:password .htpasswd: |- - resultsdb-updater:{{ resultsdb_password }} \ No newline at end of file +{% if env == 'staging' %} + {{ stg_resultsdb_httpd_user }}:{{ stg_resultsdb_httpd_password }} +{% else %} + {{ prod_resultsdb_httpd_user }}:{{ prod_resultsdb_httpd_password }} +{% endif %} \ No newline at end of file diff --git a/roles/openshift-apps/resultsdb/templates/services.yml b/roles/openshift-apps/resultsdb/templates/services.yml index c1c53fd..7f46ba7 100644 --- a/roles/openshift-apps/resultsdb/templates/services.yml +++ b/roles/openshift-apps/resultsdb/templates/services.yml @@ -1,14 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: "resultsdb-test-{{ resultsdb_test_id }}-api" + name: "resultsdb-api" labels: - environment: "test-{{ resultsdb_test_id }}" app: resultsdb spec: selector: app: resultsdb - environment: "test-{{ resultsdb_test_id }}" service: api ports: - name: api diff --git a/roles/openshift-apps/resultsdb/vars/main.yml b/roles/openshift-apps/resultsdb/vars/main.yml index 1fc1fb6..95d9ed4 100644 --- a/roles/openshift-apps/resultsdb/vars/main.yml +++ b/roles/openshift-apps/resultsdb/vars/main.yml @@ -1,9 +1,6 @@ resultsdb_publish: true -resultsdb_test_id: 'test' resultsdb_mod_wsgi_dir: '${MOD_WSGI_MODULES_DIRECTORY}' -resultsdb_secret_key: '\xe8m}\xda\xcah^)\x9fr/\x02\x14\xffO\xee\xb1\x8a\xef\xad\xb2J\x18\x9ev(\xf8\x85*Kfb' -resultsdb_db_password: 'resultsdb' resultsdb_additional_result_outcomes: [] resultsdb_image: quay.io/fedora/resultsdb:latest \ No newline at end of file