This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaddressbase.yml
83 lines (64 loc) · 2.61 KB
/
addressbase.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
- hosts: servers
vars_files:
- vars.yml
# We want the vault to be loaded conditionally, so we do if via the
# `--extra-args` command line flag
# - @vault.yml
gather_facts: true
become: true
become_user: "{{ project_name }}"
tasks:
# This isn't used as part of this play, but by baking it in at this stage, we don't have to
# download as much in the imported-db stage.
- name: Sync S3 bucket
shell: "aws s3 sync s3://pollingstations-data/ {{ private_data_path }} --exclude '*' --include '*{{ item }}*'"
with_items:
"{{ s3_years }}"
- name: Import Councils
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py import_councils -u {{ alt_boundaries_url }}"
args:
chdir: "{{ project_root }}/code/"
- name: Set ONSPD tmp path
set_fact:
onspd_tmp_path: '/tmp/onspd'
- name: Create the ONSPD tmp dir
file: state=directory path={{ onspd_tmp_path }}
- name: Download ONSPD
get_url:
url: "{{ onspd_url }}"
dest: "{{ onspd_tmp_path }}"
- name: Unzip ONSPD
shell: "unzip \\*.zip"
args:
chdir: "{{ onspd_tmp_path }}"
- name: Import ONSPD
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py import_onspd \"{{ onspd_tmp_path }}/Data\""
- name: Delete ONSPD tmp files
file:
state: absent
path: "{{ onspd_tmp_path }}"
- name: Set addressbase tmp path
set_fact:
addressbase_tmp_path: '/tmp/addressbase'
- name: Create the addressbase tmp dir
file: state=directory path={{ addressbase_tmp_path }}
- name: Download addressbase from S3
command: "aws s3 --region={{ build_region }} cp s3://pollingstations-packer-assets/addressbase/{{ addressbase_file_name }} {{ addressbase_tmp_path }}/addressbase_cleaned.csv"
- name: Import addresses
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py import_cleaned_addresses {{ addressbase_tmp_path }}"
- name: Delete addressbase tmp files
file:
state: absent
path: "{{ addressbase_tmp_path }}"
- name: Set UPRN to Council lookup path
set_fact:
uprn_to_council_path: '/tmp/uprn_to_councils.csv'
- name: Create UPRN to Council lookup
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py create_uprn_council_lookup -d {{ uprn_to_council_path }}"
- name: Import UPRN to Council lookup
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py import_uprn_council_lookup {{ uprn_to_council_path }}"
- name: Delete UPRN to Council lookup
file:
state: absent
path: "{{ uprn_to_council_path }}"