-
Notifications
You must be signed in to change notification settings - Fork 32
/
playbook-build.yml
337 lines (298 loc) · 11.6 KB
/
playbook-build.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
- name: Prepare for VM build
hosts: "{{ build_hosts | default('vagrant-ssh') }}"
gather_facts: false
pre_tasks:
- name: test configuration
tags: [init]
debug:
msg: RUNNING PLAYBOOK FOR '{{ vm_name }}' VERSION '{{ vm_version }}'
- name: testing ansible environment
tags: [init]
debug:
msg: Connecting to host '{{ inventory_hostname }}' as user '{{ ansible_user }}'
- name: Install linux-headers-generic for guest-additions
tags: [init]
when: "inventory_hostname.startswith('vagrant')"
become: true
apt:
cache_valid_time: 86400 # One day
name:
- linux-headers-generic
- name: Make local dist folder
tags: [init]
local_action:
module: file
state: directory
path: "{{ local_dist_folder }}/"
when: release_notes_locally is defined and release_notes_locally
- name: Build VM
hosts: "{{ build_hosts | default('vagrant-ssh') }}"
tasks:
# Generic Tasks
# These tasks are run for any VM build, regardless of the software installed
# They setup the VM user, commandline interface, and (optionally) desktop GUI
- name: Update system package managers (apt, pip)
tags: [init]
include_tasks: local/tasks/ensure-apt-pip.yml
- name: "Add QM user '{{ vm_user }}'"
tags: [add_user, ci_test]
import_tasks: local/tasks/add-qm-user.yml
- name: "Add release notes section for the operating system"
tags: [release_notes]
import_tasks: local/tasks/release-notes-system.yml
- name: Customise bash terminal for QM
tags: [customise-bash]
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/customise-bash.yml
- name: Install common text editors
tags: [editors]
import_role:
name: marvel-nccr.editors
vars:
editors_vm_user: "{{ vm_user }}"
- name: Add desktop GUI
tags: [ubuntu_desktop]
when: not vm_headless
import_role:
name: marvel-nccr.ubuntu_desktop
vars:
ubuntu_desktop_vm_user: "{{ vm_user }}"
ubuntu_desktop_browser: "{{ vm_browser }}"
- name: Customise GUI for QM
tags: [customise-gui]
when: not vm_headless
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/customise-gui.yml
- name: Setup QM to run simulations
tags: [simsetup]
import_tasks: local/tasks/simulation-setup.yml
# Build Specific Tasks
# These tasks can be customised for specific VM builds,
# depending on the software one requires to be installed
- name: "Add user README"
tags: [add_readme]
become: true
become_user: "{{ vm_user }}"
template:
src: local/tasks/files/README.md.j2
dest: "{{ readme_vm_path }}"
vars:
software_urls:
Abinit: https://www.abinit.org
BigDFT: http://www.bigdft.org
CP2K: https://www.cp2k.org
Fleur: http://www.flapw.de/
NWChem: https://nwchemgit.github.io/
Quantum ESPRESSO: http://www.quantum-espresso.org/
Siesta: https://gitlab.com/siesta-project/siesta
Wannier90: http://www.wannier.org
Yambo: http://www.yambo-code.org/
- name: Install plotting tools (via apt)
# TODO we may want to eventually install these with conda
# (jmol and gnuplot are already installed via conda-forge)
tags: [plotting]
import_tasks: local/tasks/plotting-tools.yml
vars:
packages: [grace, xcrysden, default-jre]
- name: install SLURM service
tags: [slurm]
import_role:
name: marvel-nccr.slurm
# TODO control version
# could install with conda, but how to set up the systemd service?
- name: install RabbitMQ server service
tags: [rabbitmq]
become: true
become_user: "{{ root_user }}"
import_tasks: local/tasks/rabbitmq.yml
# TODO control version
# could install with conda, but how to set up the systemd service?
- name: install PostrgeSQL server service
tags: [postgresql]
become: true
become_user: "{{ root_user }}"
import_tasks: local/tasks/postgresql.yml
- name: install conda+mamba
tags: [conda]
import_role:
name: chrisjsewell.conda.user_install
become: true
become_user: "{{ vm_user }}"
vars:
conda_folder: "~/.conda"
conda_installer_url: https://github.com/conda-forge/miniforge/releases/download/22.11.1-4/Mambaforge-22.11.1-4-Linux-x86_64.sh
conda_installer_checksum: sha256:16c7d256de783ceeb39970e675efa4a8eb830dcbb83187f1197abfea0bf07d30
conda_activate_alias: workon
- name: Install code environment
tags: [code-envs]
# TODO ideally this would be import_tasks, but then we can't use loop
include_tasks: local/tasks/conda-env-install.yml
vars:
conda_env: "{{ item.name }}"
code_packages: "{{ item.pkgs }}"
# TODO allow for `conda env config vars set` to be used,
# e.g. for export OMP_NUM_THREADS=1
loop:
# note here we specify exact versions of libxc/openmpi/mpich
# this is because we want conda to re-use as many packages as possible
# since re-used packages do not incur more disk memory usage
- {name: abinit, pkgs: [abinit=9, libxc=4.3.4, mpich=4.0.3]}
- {name: bigdft, pkgs: [bigdft-suite=1.9, libxc=4.3.4, mpich=4.0.3]}
- {name: cp2k, pkgs: [cp2k=9.*=*openmpi*, libxc=5.2.3, openmpi=4.1.2]}
- {name: fleur, pkgs: [fleur=6, libxc=5.2.3, openmpi=4.1.2]}
- {name: nwchem, pkgs: [nwchem=7, libxc=5.2.3, openmpi=4.1.2]}
- {name: qespresso, pkgs: [qe=7, libxc=5.2.3, openmpi=4.1.2]}
- {name: siesta, pkgs: [siesta=4.*=mpi*, libxc=5.2.3, openmpi=4.1.2]}
- {name: yambo, pkgs: [yambo=5, libxc=5.2.3, openmpi=4.1.2]}
- {name: wannier90, pkgs: [wannier90=3, libxc=5.2.3, openmpi=4.1.2]}
- {name: visualise, pkgs: [jmol, gnuplot, cif2cell, python=3.9]}
loop_control:
label: "{{ item.name }}"
- name: Install AiiDA environment
tags: [aiida-env]
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/aiida-conda-env.yml
vars:
conda_env: "{{ aiida_conda_env }}"
aiida_packages:
- python=3.9
- pip
- aiida-core=2
- aiida-core.notebook
- aiida-abinit=0.4
- aiida-cp2k=2
- aiida-quantumespresso=4
- aiida-nwchem=2
- aiida-siesta=2
- aiida-pseudo=1
- ipykernel
- jupyterlab
- jupyterlab-tour
- jupyterlab-spellchecker
- mamba_gator # Provides Conda/Mamba management as a standalone application or as extension for JupyterLab.
- name: Create an aiida-profile
tags: [aiida-profile]
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/aiida-profile.yml
vars:
name: "{{ aiida_profile }}"
aiida_run_verdi: "~/.conda/bin/conda run -n {{ aiida_conda_env }} verdi"
postgres_user: postgres
parameters:
first_name: Max
last_name: Scientist
email: aiida@localhost
institution: Quantum Mobile
db_host: localhost
db_port: 5432
db_name: aiidadb
db_username: aiida
db_password: "ne9N_LDK-*JSS"
daemon_service: true
- name: Create AiiDA Jupyter service
tags: [aiida-jupyter]
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/aiida-jupyter.yml
- name: "Create AiiDA computers"
tags: [aiida-computers]
become: true
become_user: "{{ vm_user }}"
verdi_computer:
verdi: "~/.conda/bin/conda run -n {{ aiida_conda_env }} verdi"
profile: "{{ aiida_profile }}"
label: "{{ item.l }}"
scheduler: "{{ item.s }}"
transport: core.local
hostname: localhost
work_dir: "~/.aiida_run"
mpirun_command: "mpirun -np {tot_num_mpiprocs}"
mpiprocs_per_machine: 2
configure: "--safe-interval=0"
loop:
- {l: local_direct, s: core.direct}
- {l: local_slurm, s: core.slurm}
loop_control:
label: "{{ item.l }}"
- name: "Add AiiDA Codes"
tags: [aiida-codes]
become: true
become_user: "{{ vm_user }}"
verdi_code:
verdi: ~/.conda/bin/conda run -n {{ aiida_conda_env }} verdi
profile: "{{ aiida_profile }}"
label: "{{ item.label }}"
description: "Local code for '{{ item.exec }}' in Conda env '{{ item.env }}'"
computer: local_slurm
input_plugin: "{{ item.plugin }}"
remote_abs_path: "/home/max/.conda/envs/{{ item.env }}/bin/{{ item.exec }}"
prepend_text: |
ulimit -s unlimited
eval "$(conda shell.bash hook)"
conda activate {{ item.env }}
{{ item.prepend | default('') }}
loop_control:
label: "{{ item.label }}"
loop:
- {label: qe.pw, plugin: quantumespresso.pw, env: qespresso, exec: pw.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.cp, plugin: quantumespresso.cp, env: qespresso, exec: cp.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.pp, plugin: quantumespresso.pp, env: qespresso, exec: pp.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.ph, plugin: quantumespresso.ph, env: qespresso, exec: ph.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.neb, plugin: quantumespresso.neb, env: qespresso, exec: neb.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.epw, plugin: quantumespresso.epw, env: qespresso, exec: epw.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.projwfc, plugin: quantumespresso.projwfc, env: qespresso, exec: projwfc.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.pw2wannier90, plugin: quantumespresso.pw2wannier90, env: qespresso, exec: pw2wannier90.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.dos, plugin: quantumespresso.dos, env: qespresso, exec: dos.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.q2r, plugin: quantumespresso.q2r, env: qespresso, exec: q2r.x, prepend: export OMP_NUM_THREADS=1}
- {label: qe.matdyn, plugin: quantumespresso.matdyn, env: qespresso, exec: matdyn.x, prepend: export OMP_NUM_THREADS=1}
- {label: nwchem.main, plugin: nwchem.nwchem, env: nwchem, exec: nwchem}
- {label: siesta.main, plugin: siesta.siesta, env: siesta, exec: siesta}
- {label: cp2k.main, plugin: cp2k, env: cp2k, exec: cp2k.psmp}
- {label: abinit.main, plugin: abinit, env: abinit, exec: abinit}
# TODO release notes for aiida computers/codes
- name: Download and install SSSP potentials
tags: [aiida-pseudo]
import_tasks: local/tasks/aiida-pseudo-sssp.yml
vars:
# for quantum mobile
aiida_pseudo_cmd: "~/.conda/bin/conda run -n {{ aiida_conda_env }} aiida-pseudo"
aiida_pseudo_base_folder: "{{ vm_data_folder }}"
aiida_pseudo_functional: PBE
aiida_pseudo_protocol: efficiency
aiida_pseudo_version: "1.1"
aiida_pseudo_profile: "{{ aiida_profile }}"
- name: Download and install DOJO potentials
tags: [aiida-pseudo]
import_tasks: local/tasks/aiida-pseudo-dojo.yml
vars:
# for sisesta
aiida_pseudo_cmd: "~/.conda/bin/conda run -n {{ aiida_conda_env }} aiida-pseudo"
aiida_pseudo_base_folder: "{{ vm_data_folder }}"
aiida_pseudo_functional: PBE
aiida_pseudo_relativistic: FR
aiida_pseudo_protocol: standard
aiida_pseudo_format: psml
aiida_pseudo_version: "0.4"
aiida_pseudo_profile: "{{ aiida_profile }}"
- name: aiida-example scripts
tags: [aiida-examples]
become: true
become_user: "{{ vm_user }}"
import_tasks: local/tasks/aiida-examples.yml
vars:
aiida_examples_folder: "~/Desktop/aiida-examples"
aiida_verdi_cmd: "~/.conda/bin/conda run -n {{ aiida_conda_env }} verdi"
post_tasks:
# These break idempotency,
# so only run once all other tasks have completed
- name: "Clean caches"
tags: [never, cleanup]
import_tasks: local/tasks/clean-caches.yml
- name: "Remove {{ build_dir }} content"
tags: [never, cleanup]
become: true
command: rm -rf {{ build_dir }}/*