Skip to content

Commit 7f15f35

Browse files
korlaxxalrokkrivard
authored andcommitted
Set up initial google_health-deploy branch
- Add new google_health Jenkins pipeline stage scripts - Add the abilty for Ansible to write either a file or a template depending on which has been configured for the indicator - Add Ansible template directory (special tall bookshelf) - Add the ability to keep sensitive variables in `vault.yaml` - Add google_health production params template Encrypt vault.yaml - Use templates dir - Configure start_date and end_date
1 parent 2d377ec commit 7f15f35

9 files changed

+119
-2
lines changed

ansible/ansible-deploy.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- hosts: runtime_host
33
vars_files:
44
- vars.yaml
5+
- vault.yaml
56
tasks:
67
- name: Copy and unarchive the package into the indicators runtime host directory.
78
unarchive:
@@ -18,9 +19,26 @@
1819
group: "{{ runtime_user }}"
1920
state: link
2021

22+
- name: Check to see if we have a params file to send.
23+
local_action: stat files/{{ indicator }}-params-prod.json
24+
register: file
25+
26+
- name: Check to see if we have a params template to send.
27+
local_action: stat templates/{{ indicator }}-params-prod.json.j2
28+
register: template
29+
2130
- name: Set production params file.
2231
copy:
2332
src: files/{{ indicator }}-params-prod.json
2433
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
2534
owner: "{{ runtime_user }}"
2635
group: "{{ runtime_user }}"
36+
when: file.stat.exists
37+
38+
- name: Set production params template.
39+
copy:
40+
src: templates/{{ indicator }}-params-prod.json.j2
41+
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
42+
owner: "{{ runtime_user }}"
43+
group: "{{ runtime_user }}"
44+
when: template.stat.exists
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"static_file_dir": "./static",
3+
"export_dir": "./receiving",
4+
"cache_dir": "./cache",
5+
"start_date": "2020-02-01",
6+
"end_date": "2020-05-15",
7+
"ght_key": "{{ google_health_api_key }}"
8+
}

ansible/vars.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ indicators_runtime_dir: "/home/{{ runtime_user }}/runtime"
55
package: "{{ indicator }}.tar.gz" # This is passed in the Ansible invocation.
66
python_version: "3.8.2"
77
pyenv_python_path: "/home/{{ runtime_user }}/.pyenv/versions/{{ python_version }}/bin/python"
8+
9+
# Indicators variables.
10+
google_health_api_key: "{{ vault_google_health_api_key }}"

ansible/vault.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
35386139306136373731386533393535343530623035366532343334326430313839336334646363
3+
6630646235616664386630623565363262643965376563660a386639663436616635323630356430
4+
35613139666439363161613232346463366637623238623963623364366166356131346363656432
5+
3831636539306230660a656430623166663262316230333137613633333337623338393837643331
6+
34306335636231366135383163336435613130396265333434623361376531396138353163653265
7+
33363963363032326164323161323036326436616333303738373866623335623664316565653461
8+
63646536633161623937363062663031353734303539343332633365326333353537316336383461
9+
64353265303234346633

google_health/params.json.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"static_file_dir": "./static",
33
"export_dir": "./receiving",
44
"cache_dir": "./cache",
5-
"start_date": "2020-02-01",
6-
"end_date": "2020-05-15",
5+
"start_date": "2020-01-05",
6+
"end_date": "",
77
"ght_key": ""
88
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
#
3+
# JHU: Jenkins build
4+
#
5+
6+
set -exo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Build
11+
#
12+
13+
local_indicator="google_health"
14+
15+
cd "${WORKSPACE}/${local_indicator}" || exit
16+
17+
# Set up venv
18+
python -m venv env
19+
source env/bin/activate
20+
pip install ../_delphi_utils_python/.
21+
pip install .
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Jenkins deploy
4+
#
5+
6+
set -exo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Deploy
11+
#
12+
13+
local_indicator="google_health"
14+
15+
cd "${WORKSPACE}/ansible" || exit
16+
17+
# Ansible!
18+
ansible-playbook ansible-deploy.yaml --extra-vars "indicator=${local_indicator}" -i inventory
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Jenkins package
4+
#
5+
6+
set -exo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Package
11+
#
12+
13+
local_indicator="google_health"
14+
15+
cd "${WORKSPACE}" || exit
16+
17+
# Create .tar.gz for deployment
18+
tar -czvf "${JENKINS_HOME}/artifacts/${local_indicator}.tar.gz" "${local_indicator}"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#
3+
# JHU: Jenkins test
4+
#
5+
6+
set -exo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Test
11+
#
12+
13+
local_indicator="google_health"
14+
15+
cd "${WORKSPACE}/${local_indicator}" || exit
16+
17+
# Linter
18+
env/bin/pylint delphi_"${local_indicator}"
19+
20+
# Unit tests and code coverage
21+
cd tests || exit && \
22+
../env/bin/pytest --cov=delphi_"${local_indicator}" --cov-report=term-missing

0 commit comments

Comments
 (0)