Skip to content

Commit

Permalink
Settle umask
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 4, 2023
1 parent 12993fd commit 8d75131
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

project = "Quantum Mobile"
copyright = "2020, NCCR MARVEL"
author = "Chris Sewell, Giovanni Pizzi, Leopold Talirz"
author = "Jusong Yu, Chris Sewell, Giovanni Pizzi, Leopold Talirz"

version = inventory["all"]["vars"]["vm_version"]
release = version
Expand Down
43 changes: 43 additions & 0 deletions docs/developers/build-apple-silicon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Build for Apple Silicon

Apple Silicon is the new CPU architecture for Apple Macs.
The new architecture is based on ARM64, which means that software compiled for x86_64 will not run on Apple Silicon without translation.
The VirtualBox software is not yet available for Apple Silicon, so we need to use a different virtualization software which is the [UTM](https://mac.getutm.app/).

## Install and start the VM
- Download latest version of UTM
- browse gallery to have a image setup, we select ubuntu 20.04 LTS https://docs.getutm.app/guides/ubuntu/
- The arm64 ISO image can be dowloaded from https://cdimage.ubuntu.com/releases/focal/release/
- During import and setup from ISO, select settings with all default (64GB disk space, 4096MB RAM, default cores ...)
- Create system user `max` with password `moritz` and enable auto login. This will be used for ansible deployment.
- Create a new network setting with type "Emulated VLAN" and forward port 22 to 2200 of localhost so you can ssh to VM from localhost.

<img src="images/utm_ports_mapping.png" width="350px">

You can config ssh with:
```
Host qmobile
HostName 127.0.0.1
User max
Port 2200
```
- The default `max` user is granted with the sudo permission and the password is `moritz`.

- To reboot, remember to unmount the image and boot again.

## Configure the VM

In the localhost (control machine)

Run with ansible playbook
```
BUILD_PLAYBOOK=playbook-aiidalab-qe.yml tox -e ansible -- --extra-vars "build_hosts=utm" -kK
```

It will ask for the password of `max` user, which is `moritz`.

## troubleshotings

### import from utm copy

- If you see "Failed to access data from shortcut", try the methods from https://github.com/utmapp/UTM/discussions/3774
Binary file added docs/developers/images/utm_ports_mapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ users/troubleshoot.md
developers/customize.md
developers/build-vagrant.md
developers/build-cloud.md
developers/build-apple-silicon.md
developers/roles.md
```

Expand Down
3 changes: 1 addition & 2 deletions local/tasks/aiidalab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
become: true
become_user: "{{ vm_user }}"
command: "docker run -d --name qeapp -p 8899:8888 --volume /home/{{ vm_user }}/qeapp-home:/home/jovyan -e JUPYTER_TOKEN='max' -e NB_UMASK=002 --restart always {{ vm_qeapp_image }}"
when: qe_container_stat.stdout == ""
when: qe_container_stat.stdout == ""

- name: Copy AiiDAlab logo
become: true
Expand All @@ -45,4 +45,3 @@
Terminal=false
Icon=/usr/share/icons/aiidalab-qe-logo.png
Type=Application
8 changes: 8 additions & 0 deletions local/tasks/customise-bash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
- regexp: HISTFILESIZE=
line: HISTFILESIZE=100000

- name: Set umask to 002
blockinfile:
path: "${HOME}/.bashrc"
marker: "# {mark} ANSIBLE MANAGED BLOCK (umask)"
block: |
# Set umask to 002
umask 002
- name: hide possible sudo message
file:
path: ~/.sudo_as_admin_successful
Expand Down
6 changes: 3 additions & 3 deletions local/tasks/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
name: geerlingguy.docker
vars:
docker_users:
- "{{ vm_user }}"
- "{{ vm_user }}"
when: ansible_architecture == 'x86_64'

- name: Install docker (arm64)
include_role:
name: geerlingguy.docker_arm
vars:
docker_users:
- "{{ vm_user }}"
- "{{ vm_user }}"
when: ansible_architecture == 'aarch64'

- name: Install docker pip
include_role:
name: geerlingguy.pip
vars:
pip_install_packages:
- docker
- docker
23 changes: 23 additions & 0 deletions local/tasks/files/README-qeapp.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Welcome to {{ vm_name }} version {{ vm_version }}

*Quantum Mobile* is a Virtual Machine for computational materials science, distributed by the {{ vm_author }}.

It comes with a collection of software packages for quantum mechanical calculations, including:

{% for name, url in software_urls.items() %}
* [{{ name }}]({{ url }})
{% endfor %}

all of which are set up and ready to be used on their own or through [AiiDA](http://www.aiida.net).

# Getting started

* Start the Quantum ESPRESSO app by double-clicking on the icon on the desktop.

* If the virtual machine is just started, you may need to wait a few minutes for the server to be fully ready. If you see an error message, try again after a few minutes.

* The data you create over the app can be accessed from the `~/qeapp-home` folder. Vise versa, you can copy files into this folder to make them available in the app.

* For more information on how to use the app, see the [Quantum ESPRESSO app documentation](https://aiidalab-quantumespresso.readthedocs.io/en/latest/).

For troubleshooting and other information, see: {{ qm_homepage }}.
3 changes: 1 addition & 2 deletions playbook-aiidalab-qe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
become: true
become_user: "{{ vm_user }}"
template:
src: local/tasks/files/README.md.j2
src: local/tasks/files/README-qeapp.md.j2
dest: "{{ readme_vm_path }}"
vars:
software_urls:
Expand All @@ -98,7 +98,6 @@
# Build Specific Tasks
# These tasks can be customised for specific VM builds,
# depending on the software one requires to be installed

- name: Install docker and docker-compose
tags: [docker]
import_tasks: local/tasks/docker.yml
Expand Down

0 comments on commit 8d75131

Please sign in to comment.