• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

templates/23-Nov-2023-305154

test-local-vars/23-Nov-2023-2517

vars/23-Nov-2023-1211

.gitignoreD23-Nov-202326 43

README.mdD23-Nov-20234 KiB148105

VagrantfileD23-Nov-2023522 1917

ansible.cfgD23-Nov-202358 43

backup-db-playbook.ymlD23-Nov-20232.1 KiB7675

hostsD23-Nov-2023279 1914

requirements.ymlD23-Nov-202355 43

roles.ymlD23-Nov-2023170 86

setup-playbook.ymlD23-Nov-20235.6 KiB202190

upgrade-playbook.ymlD23-Nov-2023153 86

README.md

1# Ansible for Survey Tool
2
3These are ansible scripts for setup and maintenance of the Survey Tool.
4
5## Scope
6
7Right now, the test setup mostly controls Tomcat, but not the nginx proxy
8due to public port issues (https).
9
10## Setup
11
12### Setup: Control system
13
14This is your local system, where you control the others from.
15
16- Install Ansible <https://ansible.com>
17- Install some prereqs:
18
19```shell
20ansible-galaxy install -r roles.yml
21```
22
23- Make sure you can `ssh` into all of the needed systems. For example,
24`ssh cldr-ref.unicode.org` should succeed without needing a password.
25
26- You should be able to run `ansible all -m ping` and get something back
27like the following:
28
29```shell
30cldr-ref.unicode.org | SUCCESS => {
31    "ansible_facts": {
32        "discovered_interpreter_python": "/usr/bin/python"
33    },
34    "changed": false,
35    "ping": "pong"
36}
37```
38
39### Setup: Managed systems
40
41- Install python3. Make sure `python --version`
42or `python3 --version` returns "Python 3…"
43
44- TODO: these shouldn't be needed, but they are. Here's the entire
45install command:
46
47```shell
48sudo apt-get update && sudo apt-get install python3 python-apt python3-pymysql
49```
50
51### Setup: surveytool keypair
52
53Create a RSA keypair with no password for the buildbot:
54
55```shell
56mkdir -p ./local-vars
57ssh-keygen -t rsa -b 4096 -f ./local-vars/surveytool -P '' -C 'surveytool deploy'
58```
59
60The contents of the `local-vars/surveytool.pub` file is used for the
61`key:` parameter below in `local.yml`. The `local-vars/surveytool`
62private key is used in the secret `RSA_KEY_SURVEYTOOL`.
63
64Then setup github secrets as shown:
65
66- `SMOKETEST_HOST` -
67  hostname of smoketest
68- `SMOKETEST_PORT` -
69  port of smoketest
70- `RSA_KEY_SURVEYTOOL` -
71  contents of `local-vars/surveytool` (the secret key)
72- `SMOKETEST_KNOWNHOSTS` -
73  run `ssh-keyscan smoketest.example.com` where _smoketest.example.com_
74  is the name of the smoketest server.  Put the results into this
75  secret. One of these lines should match `~/.ssh/known_hosts` on your
76  own system when you ssh into smoketest.
77  Try `grep -i smoke ~/.ssh/known_hosts`
78
79Create a folder "cldrbackup" inside local-vars
80```shell
81mkdir -p ./local-vars/cldrbackup
82```
83
84Add three files inside local-vars/cldrbackup-vars: id_rsa, id_rsa.pub, and known_hosts. These must correspond to the public key for cldrbackup on corp.unicode.org. Copy existing versions if you have them. Otherwise, create new ones with `ssh-keygen -t rsa` and copy the public key to corp.unicode.org with `ssh-copy-id -i ~/.ssh/id_rsa cldrbackup@corp.unicode.org`
85
86### Setup: Config file
87
88- Create a file `local-vars/local.yml` matching the example values in [test-local-vars/local.yml](test-local-vars/local.yml) (but with a secure password instead of `hunter42`!.)
89
90```yaml
91mysql_users:
92  - name: surveytool
93    host: localhost
94    password: hunter42
95    priv: 'cldrdb.*:ALL'
96surveytooldeploy:
97  password: hunter43
98  vap: hunter44
99  testpw: hunter45
100  oldversion: 36
101  newversion: 37
102  key: ssh-rsa …  ( SSH key goes here)
103```
104
105## Configure
106
107Run the setup playbook.
108
109```shell
110ansible-playbook --check setup-playbook.yml
111```
112
113This is in dry run mode. When it looks good to you, take the
114`--check` out and run it again.
115
116You can also use the `-l cldr-smoke.unicode.org` option to limit
117the operation to a single host.
118
119## Local Test
120
121- install vagrant and some provider such as virtualbox or libvirt
122
123```shell
124vagrant up
125```
126
127- To log into the new host, run `vagrant ssh`
128
129- To iterate, trying to reapply ansible, run `vagrant provision --provision-with=ansible`
130
131- to deploy ST to this, use the following:
132
133```shell
134(cd ../../cldr-apps ; ant war) # to build ST if not already built
135vagrant ssh -- sudo -u surveytool /usr/local/bin/deploy-to-tomcat.sh $(git rev-parse HEAD) < ../../cldr-apps/cldr-apps.war
136```
137
138- Now you should be able to login at <http://127.0.0.1:8880/cldr-apps/>
139
140- If you need to get directly to the tomcat server, use:
141
142```shell
143vagrant ssh -- -L 8080:127.0.0.1:8080
144# leave this shell window open.
145```
146
147Then, you can go to <http://127.0.0.1:8080> and directly access tomcat.
148