Name Date Size #Lines LOC

..--

roles/openliberty/H25-Apr-2025-13480

templates/H25-Apr-2025-262176

test-local-vars/H25-Apr-2025-3421

vars/H25-Apr-2025-4131

.gitignoreH A D25-Apr-202526 43

README.mdH A D25-Apr-20257.1 KiB211150

VagrantfileH A D25-Apr-2025755 2624

ansible.cfgH A D25-Apr-202558 43

backup-db-playbook.ymlH A D25-Apr-20252.2 KiB7876

ccc-playbook.ymlH A D25-Apr-20252 KiB6965

certbot-playbook.ymlH A D25-Apr-2025535 1817

cldr-apps-playbook.ymlH A D25-Apr-20252 KiB6864

hostname-playbook.ymlH A D25-Apr-2025195 86

hostsH A D25-Apr-2025449 2821

monitoring-playbook.ymlH A D25-Apr-2025400 1513

mysql-playbook.ymlH A D25-Apr-2025367 1716

nginx-playbook.ymlH A D25-Apr-20251.8 KiB5755

openliberty-playbook.ymlH A D25-Apr-20253.2 KiB9188

packages-playbook.ymlH A D25-Apr-2025405 1815

redact-db-playbook.ymlH A D25-Apr-20252.3 KiB7673

requirements.ymlH A D25-Apr-2025418 188

server-playbook.ymlH A D25-Apr-20252.2 KiB7975

setup-playbook.ymlH A D25-Apr-2025455 129

upgrade-playbook.ymlH A D25-Apr-2025510 2017

vagrant-playbook.ymlH A D25-Apr-2025210 41

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 OpenLiberty, 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 requirements.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 [email protected]`
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 secure passwords instead of `hunter42`, ...!
89
90```yaml
91cldradmin_pw: hunter46 # needs to match cldradmin pw below
92mysql_users:
93  # this is the account used by the survey tool itself
94  # password will match /var/lib/openliberty/usr/servers/cldr/server.env
95  - name: surveytool
96    host: localhost
97    password: hunter42
98    priv: 'cldrdb.*:ALL'
99  # this is the account used for administrative tasks
100  # password will match /home/cldradmin/.my.sql
101  - name: cldradmin
102    password: hunter46
103    priv: 'cldrdb.*:ALL/*.*:PROCESS'
104    append_privs: yes
105# this is the account used for deployment
106surveytooldeploy:
107  # TODO: surveytooldeploy.password appears to be unused?
108  password: hunter43
109  # vap will match CLDR_VAP in /srv/st/config/cldr.properties
110  vap: hunter44
111  # testpw will match CLDR_TESTPW in /srv/st/config/cldr.properties
112  testpw: hunter45
113  oldversion: 39
114  newversion: 40
115  key: ssh-rsa …  ( SSH key goes here)
116  certbot_admin_email: [email protected]
117  certbot_certs:
118    - domains:
119      - cldr-ref.unicode.org
120```
121
122## Setup: cldrcc
123
124```shell
125mkdir -p local-vars/cldrcc
126ssh-keygen -t rsa -b 2048 -C 'CLDR Commit Checker' -f local-vars/cldrcc/id_rsa
127```
128
129
130## Configure
131
132Run the setup playbook.
133
134```shell
135ansible-playbook --check setup-playbook.yml
136```
137
138This is in dry run mode. When it looks good to you, take the
139`--check` out and run it again.
140
141You can also use the `-l cldr-smoke.unicode.org` option to limit
142the operation to a single host.
143
144## Local Test
145
146Here’s how to deploy the SurveyTool locally and try it out.
147
148### Build
149
150You need a server zipfile to deploy.  This is a file such as `cldr-apps.zip`. When expanded, it contains a directory tree beginning with `wlp/`.
151
152#### Option A: Local Build
153
154- Prerequisites: See <https://cldr.unicode.org/development/maven> and follow instructions to be able to run `mvn package` as shown on that page.
155
156- You can then create a server zipfile locally with maven using these command (from the top `cldr/` directory).  The first command does a full build of CLDR, but skips running tests.
157
158```shell
159mvn --file=tools/pom.xml install -DskipTests=true
160mvn --file=tools/pom.xml -pl cldr-apps liberty:package
161```
162
163- The output file will be in `tools/cldr-apps/target/cldr-apps.zip`
164
165
166#### Option B: Download a Build
167
168- Server Builds are actually attached to each action run in <https://github.com/unicode-org/cldr/actions/workflows/maven.yml>, look for an artifact entitled `cldr-apps-server` at the bottom of a run.
169
170- *Warning*: Clicking on this artifact will download a zipfile named `cldr-apps-server.zip` which _contains_ `cldr-apps.zip`.  Double clicking or automatic downloading will often extract one too many levels of zipfiles. If you see a folder named `wlp` then you have extracted too much. From the command line you can unpack with `unzip cldr-apps-server.zip` which will extract `cldr-apps.zip`.
171
172### Deploy
173
174- install [vagrant](https://www.vagrantup.com) and some provider such as virtualbox or libvirt, see vagrant docs.
175
176- vagrant up!
177
178```shell
179# (this directory)
180cd tools/scripts/ansible
181vagrant up
182```
183
184- To log into the new host, run `vagrant ssh`
185
186- To iterate, trying to reapply ansible, run `vagrant provision --provision-with=ansible`
187
188- to deploy your built server to this, use the following:
189
190```shell
191# Note 1: $(git rev-parse HEAD) just turns into a full git hash such as 72dda8d7386087bf6087de200b5edc002feca2f2, you can use an explicit hash instead.
192# Note 2: change ../../cldr-apps/target/cldr-apps.zip to point to your cldr-apps.zip file if moved
193vagrant ssh -- sudo -u surveytool /usr/local/bin/deploy-to-openliberty.sh $(git rev-parse HEAD) < ../../cldr-apps/target/cldr-apps.zip
194```
195
196- Now you should be able to login at <http://127.0.0.1:9081/cldr-apps/>
197
198- Use the user `admin@` and the password set in `surveytooldeploy.vap` above.
199
200- *Note*: <http://127.0.0.1:8880> will go to the nginx proxy, but it has login problems, see <https://unicode-org.atlassian.net/browse/CLDR-14321>
201
202### Operation
203
204- the mvn build and `deploy-to-openliberty.sh` steps above can be repeated to redeploy a new version of the server code
205- `vagrant ssh` to login and poke around at the server
206- `sudo nano /srv/st/config/cldr.properties` to edit the configuration file (will be created automatically at first ST boot, restart server to pickup changes).
207- `sudo journalctl -f` to watch server logs
208- `sudo systemctl restart openliberty@cldr` to restart the server
209- Logs are in `/var/log/openliberty/cldr`
210- `sudo -u cldradmin mysql cldrdb` will give you the raw SQL prompt
211