|
| 1 | +# Build Your Own OS Image |
| 2 | + |
| 3 | +You can pre-build an image with all the engines you need. This can be faster |
| 4 | +than uploading an engine each time/creating an engine when configuring a node. |
| 5 | + |
| 6 | +The [packer](https://www.hashicorp.com/en/products/packer) utility is used |
| 7 | +to build images. It must be installed beforehand. |
| 8 | +See [documentation](https://developer.hashicorp.com/packer/install). |
| 9 | + |
| 10 | +The details of creation will vary for different targets, |
| 11 | +but the essence will be common. |
| 12 | + |
| 13 | +The main configuration file for `packer` is the `*.pkr.hcl` file. |
| 14 | +It specifies which plugin to use in the `packer` section, |
| 15 | +what to use as OS image source in the `source` section and |
| 16 | +how to build it in the `build` section. |
| 17 | +The contents of this file will be different for different OS and clouds. |
| 18 | +The common parts are in the scripts listed in the `source` section. |
| 19 | + |
| 20 | +## FLEUR Engine on Debian 12 at Hetzner Cloud |
| 21 | + |
| 22 | +In Hetzner Cloud, the OS image is called a "snapshot". |
| 23 | +The snapshot can be used as a base for creating a "server". |
| 24 | + |
| 25 | +You need to create a project in HCloud and create a read and write API key |
| 26 | +in it. Then specify this API key in the `HCLOUD_TOKEN` environment variable. |
| 27 | +For example, `export HCLOUD_TOKEN=“xxxx”`. |
| 28 | + |
| 29 | +The main configuration file for the build is `hcloud-debian-12-fleur.pkr.hcl`. |
| 30 | +Most likely you need to change the `location` and `server_type` in the |
| 31 | +`source` section to match your HCloud project's settings. |
| 32 | + |
| 33 | +There is a list of provision shell scripts in the `build` section. |
| 34 | +The engine build script is located in the `install-fleur.sh` file. |
| 35 | +The rest of the scripts perform common operations to prepare an OS image |
| 36 | +and will not be significantly different for other OS/clouds/engines. |
| 37 | + |
| 38 | +Let's build an image. To do this, install required `packer` plugins: |
| 39 | + |
| 40 | +```sh |
| 41 | +packer init ./hcloud-debian-12-fleur.pkr.hcl |
| 42 | +``` |
| 43 | + |
| 44 | +Then run build script: |
| 45 | + |
| 46 | +```sh |
| 47 | +packer build ./hcloud-debian-12-fleur.pkr.hcl |
| 48 | +``` |
| 49 | + |
| 50 | +This can take 15 to 20 minutes. |
| 51 | +If everything is successful, the last line will show the image ID. Remember this ID - you will need to specify it in `yascheduler.conf`. |
| 52 | + |
| 53 | +``` |
| 54 | +--> hcloud.debian: A snapshot was created: 'fleur-debian-xxxxx' (ID: 123123123) |
| 55 | +``` |
| 56 | + |
| 57 | +As a result, we have an OS image (snapshot) with the usual |
| 58 | +Debian 12 with `inpgen` and `fleur` already installed. |
| 59 | + |
| 60 | +Let's configure `yascheduler` to use our OS image. |
| 61 | +Setup `db`, `local` and `remote` sections in `yascheduler.conf` as usual. Add `clouds` and engines sections: |
| 62 | + |
| 63 | +```ini |
| 64 | +[engine.inpgen] |
| 65 | +spawn = inpgen -explicit -inc +all -f aiida.in > shell.out 2> out.error |
| 66 | +check_cmd = ps -eocomm= | grep -q inpgen |
| 67 | +input_files = aiida.in |
| 68 | +output_files = aiida.in inp.xml default.econfig shell.out out out.error scratch struct.xsf |
| 69 | + |
| 70 | +[engine.fleur] |
| 71 | +spawn = fleur -minimalOutput -wtime 360 > shell.out 2> out.error |
| 72 | +check_cmd = ps -eocomm= | grep -q fleur |
| 73 | +input_files = inp.xml |
| 74 | +output_files = inp.xml kpts.xml sym.xml relax.xml shell.out out.error out out.xml FleurInputSchema.xsd FleurOutputSchema.xsd juDFT_times.json cdn1 usage.json |
| 75 | + |
| 76 | +[clouds] |
| 77 | +; Your API key |
| 78 | +hetzner_token = xxx |
| 79 | +; Your preffered server type. |
| 80 | +; The disk should be at least as large as the snapshot. |
| 81 | +hetzner_server_type = cpx21 |
| 82 | +; It's best to use the same location as the snapshot. |
| 83 | +; This way servers will be created faster. |
| 84 | +hetzner_location = fsn1 |
| 85 | +; OS image ID that you should have memorized earlier. |
| 86 | +; You can always look under Snapshots in HCloud Dashboard. |
| 87 | +hetzner_image_name = 237472643 |
| 88 | +``` |
| 89 | + |
| 90 | +With this configuration, `yascheduler` will build servers from our |
| 91 | +OS image with pre-installed engines. This way, after spending time once, |
| 92 | +we don't waste time building/loading the engine every time. |
0 commit comments