From e1ac7c1e46191864659ca20115a3f91641c40851 Mon Sep 17 00:00:00 2001 From: euanmillar Date: Tue, 20 Feb 2024 20:33:27 +0000 Subject: [PATCH] Amends to countryconfig files for configurability --- .github/workflows/deploy-prod.yml | 4 +- .github/workflows/generate-demo-data.yml | 48 ------------------- .../docker-compose.production-deploy.yml | 3 -- .../docker-compose.staging-deploy.yml | 3 -- infrastructure/server-setup/backups.yml | 16 ------- infrastructure/server-setup/development.yml | 4 +- infrastructure/server-setup/production.yml | 2 +- infrastructure/server-setup/qa.yml | 9 ---- infrastructure/server-setup/staging.yml | 2 +- src/data-seeding/employees/handler.ts | 5 +- .../employees/source/prod-employees.csv | 1 + 11 files changed, 11 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/generate-demo-data.yml create mode 100644 src/data-seeding/employees/source/prod-employees.csv diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index b0dd118a0..01e8f9110 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -30,8 +30,8 @@ jobs: secret: ${{ github.TOKEN }} approvers: euanmillar,rikukissa minimum-approvals: 1 - issue-title: 'Deploy (Prod): core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }}' - issue-body: 'Please approve or deny the deployment of core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }} to production' + issue-title: 'Deploy (${{ github.event.inputs.environment }}): core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }}' + issue-body: 'Please approve or deny the deployment of core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }} to ${{ github.event.inputs.environment }}' exclude-workflow-initiator-as-approver: false - name: Clone core uses: actions/checkout@v3 diff --git a/.github/workflows/generate-demo-data.yml b/.github/workflows/generate-demo-data.yml deleted file mode 100644 index 9ab7fb25b..000000000 --- a/.github/workflows/generate-demo-data.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. -# -# OpenCRVS is also distributed under the terms of the Civil Registration -# & Healthcare Disclaimer located at http://opencrvs.org/license. -# -# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. -name: Generate demo data - -on: - workflow_dispatch: - inputs: - branch: - description: 'Branch to run from' - required: false - default: 'develop' - environment: - type: choice - description: Environment to deploy to - required: true - options: - - production - - qa - - staging - -jobs: - generate-demo-data: - environment: ${{ github.event.inputs.environment }} - runs-on: ubuntu-20.04 - strategy: - matrix: - node-version: [14.17.0] - steps: - - name: Checking out git repo - uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.branch }} - - name: Install dependencies - run: yarn install - - name: Start generating test data - run: yarn data-generator - env: - COUNTRY_CONFIG_HOST: ${{ vars.COUNTRY_CONFIG_HOST }} - AUTH_HOST: ${{ vars.AUTH_HOST }} - GATEWAY_HOST: ${{ vars.GATEWAY_HOST }} - CONFIG_HOST: ${{ vars.CONFIG_HOST }} - CONCURRENCY: ${{ vars.CONCURRENCY }} diff --git a/infrastructure/docker-compose.production-deploy.yml b/infrastructure/docker-compose.production-deploy.yml index bcbb7e900..55849ed59 100644 --- a/infrastructure/docker-compose.production-deploy.yml +++ b/infrastructure/docker-compose.production-deploy.yml @@ -39,7 +39,6 @@ services: metrics: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} - MONGO_URL=mongodb://metrics:${METRICS_MONGODB_PASSWORD}@mongo1,mongo2/metrics?replicaSet=rs0 @@ -48,7 +47,6 @@ services: auth: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} deploy: @@ -56,7 +54,6 @@ services: user-mgnt: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} - MONGO_URL=mongodb://user-mgnt:${USER_MGNT_MONGODB_PASSWORD}@mongo1,mongo2/user-mgnt?replicaSet=rs0 diff --git a/infrastructure/docker-compose.staging-deploy.yml b/infrastructure/docker-compose.staging-deploy.yml index c658af0b3..4adea8ac3 100644 --- a/infrastructure/docker-compose.staging-deploy.yml +++ b/infrastructure/docker-compose.staging-deploy.yml @@ -39,7 +39,6 @@ services: metrics: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} - MONGO_URL=mongodb://metrics:${METRICS_MONGODB_PASSWORD}@mongo1/metrics?replicaSet=rs0 @@ -48,7 +47,6 @@ services: auth: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} deploy: @@ -56,7 +54,6 @@ services: user-mgnt: environment: - - QA_ENV=true - NODE_ENV=production - SENTRY_DSN=${SENTRY_DSN} - MONGO_URL=mongodb://user-mgnt:${USER_MGNT_MONGODB_PASSWORD}@mongo1/user-mgnt?replicaSet=rs0 diff --git a/infrastructure/server-setup/backups.yml b/infrastructure/server-setup/backups.yml index ca6b9d31f..e5201a12c 100644 --- a/infrastructure/server-setup/backups.yml +++ b/infrastructure/server-setup/backups.yml @@ -92,22 +92,6 @@ tags: - backups - - name: Check if authorized_keys already exists - stat: - path: '{{ external_backup_server_user_home }}/.ssh/authorized_keys' - register: file_check - tags: - - backups - - - name: Ensure .ssh directory exists for external backup server user - file: - path: '{{ external_backup_server_user_home }}/.ssh' - state: directory - owner: '{{ external_backup_server_user }}' - mode: '0700' - tags: - - backups - - name: Ensure backup application servers can login to backup server blockinfile: path: '{{ external_backup_server_user_home }}/.ssh/authorized_keys' diff --git a/infrastructure/server-setup/development.yml b/infrastructure/server-setup/development.yml index bb41b723e..3779a78d0 100644 --- a/infrastructure/server-setup/development.yml +++ b/infrastructure/server-setup/development.yml @@ -18,8 +18,8 @@ all: sudoer: true docker-manager-first: - dev: - qa: # @todo set this to be the hostname of your target server + hosts: + dev: # @todo set this to be the hostname of your target server ansible_host: '44.44.44.44' # @todo set this to be the IP address of your server data_label: data1 # for manager machines, this should always be "data1" diff --git a/infrastructure/server-setup/production.yml b/infrastructure/server-setup/production.yml index 57f052224..1290fd729 100644 --- a/infrastructure/server-setup/production.yml +++ b/infrastructure/server-setup/production.yml @@ -50,5 +50,5 @@ docker-workers: backups: hosts: - qa: + backup: # @todo set this to be the hostname of your backup server ansible_host: '66.66.66.66' diff --git a/infrastructure/server-setup/qa.yml b/infrastructure/server-setup/qa.yml index 3069e11b0..d584e5987 100644 --- a/infrastructure/server-setup/qa.yml +++ b/infrastructure/server-setup/qa.yml @@ -28,15 +28,6 @@ all: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABg...Z/rhU= provision@github-runner-243 # example provision user key - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABg...Z/rhU= provision@github-runner-244 # example provision user key - # If the machine is repurposed to also be the backup host, we need to add more keys to the authorized_keys file so that - # when the application servers get provisioned, the provision user of this machine can be used. - # - # @todo remove this key if the machine is not used as a backup host. - # Otherwise, add the public key of the private key that's used for the "provision" user on the server of which backups this machine hosts. - additional_keys_for_provisioning_user: - - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABg...Z/rhU= provision@github-runner-243 # example provision user key - - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABg...Z/rhU= provision@github-runner-244 # example provision user key - docker-manager-first: hosts: qa: # @todo set this to be the hostname of your target server diff --git a/infrastructure/server-setup/staging.yml b/infrastructure/server-setup/staging.yml index b4778341d..74d4d8ee7 100644 --- a/infrastructure/server-setup/staging.yml +++ b/infrastructure/server-setup/staging.yml @@ -46,5 +46,5 @@ docker-workers: {} # @todo if you do not intend to set up automatic sync from the backup server, you can remove this section. backups: hosts: - qa: + backup: # @todo set this to be the hostname of your backup server ansible_host: '66.66.66.66' # set this to be the IP address of your backup server diff --git a/src/data-seeding/employees/handler.ts b/src/data-seeding/employees/handler.ts index 59aee343b..09198a79b 100644 --- a/src/data-seeding/employees/handler.ts +++ b/src/data-seeding/employees/handler.ts @@ -8,12 +8,15 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { QA_ENV } from '@countryconfig/constants' import { readCSVToJSON } from '@countryconfig/utils' import { Request, ResponseToolkit } from '@hapi/hapi' export async function usersHandler(_: Request, h: ResponseToolkit) { const users: unknown[] = await readCSVToJSON( - './src/data-seeding/employees/source/default-employees.csv' + process.env.NODE_ENV === 'production' && !QA_ENV + ? './src/data-seeding/employees/source/prod-employees.csv' + : './src/data-seeding/employees/source/test-employees.csv' ) return h.response(users) } diff --git a/src/data-seeding/employees/source/prod-employees.csv b/src/data-seeding/employees/source/prod-employees.csv new file mode 100644 index 000000000..323e18b82 --- /dev/null +++ b/src/data-seeding/employees/source/prod-employees.csv @@ -0,0 +1 @@ +primaryOfficeId,givenNames,familyName,systemRole,role,mobile,username,email,password \ No newline at end of file