MOS VM: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
(→‎MOS/VM: doku aktualisiert)
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
{{Projekt
{{Projekt
|image=Mos_vm.png
|image=Mos_vm.png
|involved=[[User:queltos]]
|involved=[[User:queltos| queltos]], [[User:Hetti| Hetti]]
|startdate=21.01.2013
|startdate=21.01.2013
|status=awesome
|status=awesome
|wtf=Build your own virtual machine for MOS development using Vagrant
|wtf=Build your own virtual machine for [https://metalab.at/wiki/Metalab_OS MOS] development using Vagrant
|hidden=false
|hidden=false
}}
}}


Build your own virtual machine for MOS development using Vagrant.
Build your own virtual machine for [https://metalab.at/wiki/Metalab_OS MOS] development using Vagrant.


Done with:
Done with:
* Ubuntu 12.04 LTS 64bit
* Debian Bullseye (Debian 11)
* Oracle VM VirtualBox Manager 4.1.12_Ubuntu
* Oracle VM VirtualBox Manager 6 and further
* Vagrant 1.4.3 (downloaded the .deb from http://www.vagrantup.com/downloads.html and installed with GDebi as the version provided by Ubuntu won't work)
* Vagrant 2.x.x
 




'''Checkout MOS from github'''
'''Checkout MOS from github'''
* https://github.com/Metalab/mos.git
<pre>
<pre>
$ git clone https://github.com/Metalab/mos.git
$ https://github.com/Metalab/mos.git
</pre>
</pre>


Zeile 35: Zeile 35:
<pre>
<pre>
Bringing machine 'default' up with 'virtualbox' provider...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'debian-7.4.0-amd64_virtualbox.box' was not found. Fetching box from specified URL for
==> default: Importing base box 'debian/bullseye64'...
the provider 'virtualbox'. Note that if the URL does not have
==> default: Matching MAC address for NAT networking...
a box for this provider, you should interrupt Vagrant now and add
==> default: Checking if box 'debian/bullseye64' version '11.20220912.1' is up to date...
the box yourself. Otherwise Vagrant will attempt to download the
==> default: Setting the name of the VM: mos_metalab_default_1670797153813_2335
full box prior to discovering this error.
==> default: Clearing any previously set network interfaces...
Downloading box from URL: https://dl.dropboxusercontent.com/s/c7z3xqr0ewxjalk/debian-7.4.0-amd64_virtualbox.box
==> default: Preparing network interfaces based on configuration...
Extracting box...te: 4217k/s, Estimated time remaining: --:--:--)
    default: Adapter 1: nat
Successfully added box 'debian-7.4.0-amd64_virtualbox.box' with provider 'virtualbox'!
==> default: Forwarding ports...
[default] Importing base box 'debian-7.4.0-amd64_virtualbox.box'...
    default: 8000 (guest) => 8000 (host) (adapter 1)
[default] Matching MAC address for NAT networking...
    default: 22 (guest) => 2222 (host) (adapter 1)
[default] Setting the name of the VM...
==> default: Booting VM...
[default] Clearing any previously set forwarded ports...
==> default: Waiting for machine to boot. This may take a few minutes...
[default] Clearing any previously set network interfaces...
    default: SSH address: 127.0.0.1:2222
[default] Preparing network interfaces based on configuration...
    default: SSH username: vagrant
[default] Forwarding ports...
    default: SSH auth method: private key
[default] -- 22 => 2222 (adapter 1)
    default:
[default] -- 8000 => 8000 (adapter 1)
    default: Vagrant insecure key detected. Vagrant will automatically replace
[default] Booting VM...
    default: this with a newly generated keypair for better security.
[default] Waiting for machine to boot. This may take a few minutes...
    default:
[default] Machine booted and ready!
    default: Inserting generated public key within guest...
[default] The guest additions on this VM do not match the installed version of
    default: Removing insecure key from the guest if it's present...
VirtualBox! In most cases this is fine, but in rare cases it can
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
prevent things such as shared folders from working properly. If you see
==> default: Machine booted and ready!
shared folder errors, please make sure the guest additions within the
==> default: Checking for guest additions in VM...
virtual machine match the version of VirtualBox you have installed on
    default: The guest additions on this VM do not match the installed version of
your host and reload your VM.
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 6.0.0 r127566
    default: VirtualBox Version: 7.0
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /vagrant => <YOUR LOCAL SHARED FOLDER PATH>
==> default: Running provisioner: shell...
    default: Running: /tmp/vagrant-shell20221211-25251-r8t8xa.sh


Guest Additions Version: 4.2.16
#####
VirtualBox Version: 4.1
<various packet update operations>
[default] Mounting shared folders...
#####
[default] -- /vagrant
[default] Running provisioner: shell...
[default] Running: /tmp/vagrant-shell20140221-5693-1bu2kai
stdin: is not a tty


PLAY [all] ********************************************************************  
    default:
    default: PLAY [all] *********************************************************************
    default:
    default: TASK [Gathering Facts] *********************************************************
    default: ok: [localhost]
    default:
    default: TASK [link /mos -> /vagrant] ***************************************************
    default: changed: [localhost]
    default:
    default: TASK [Install packages] ********************************************************
    default: changed: [localhost]
    default:
    default: TASK [add locale de_DE.UTF-8] **************************************************
    default: changed: [localhost]
    default:
    default: TASK [Upgrade pip3] ************************************************************
    default: changed: [localhost]
    default:
    default: TASK [Install python modules] **************************************************
    default: changed: [localhost] => (item=/vagrant/requirements.txt)
    default: changed: [localhost] => (item=/vagrant/requirements-dev.txt)
    default:
    default: TASK [check the existence of the secret_key.py file and create one if it does not exist] ***
    default: ok: [localhost]
    default:
    default: TASK [generate random django secret] *******************************************
    default: skipping: [localhost]
    default:
    default: TASK [generate mos sqlite database] ********************************************
    default: ok: [localhost]
    default:
    default: TASK [django makemigrations] ***************************************************
    default: ok: [localhost]
    default:
    default: TASK [django migrate] **********************************************************
    default: ok: [localhost]
    default:
    default: TASK [Create Admin User] *******************************************************
    default: skipping: [localhost]
    default:
    default: TASK [django loaddata] *********************************************************
    default: skipping: [localhost]
    default:
    default: TASK [Activate virtualenv on vagrant ssh] **************************************
    default: changed: [localhost]
    default:
    default: TASK [Change into mos dir on vagrant ssh] **************************************
    default: changed: [localhost]
    default:
    default: PLAY RECAP *********************************************************************
    default: localhost                  : ok=12  changed=7    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0


GATHERING FACTS ***************************************************************
</pre>
ok: [localhost]


TASK: [apt update_cache=yes] **************************************************
After booting up you will be greeted with our Info Screen with the next steps.
ok: [localhost]
<pre>
 
==> default: Machine 'default' has a post `vagrant up` message. This is a message
TASK: [apt pkg=build-essential] ***********************************************
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
changed: [localhost]
==> default:
 
==> default: ======================================================
TASK: [pip requirements=/vagrant/requirements.txt] ****************************
==> default:
changed: [localhost]
==> default:  
 
==> default: ███╗  ███╗███████╗████████╗ █████╗ ██╗      █████╗ ██████╗
TASK: [link /mos -> /vagrant] *************************************************
==> default: ████╗ ████║██╔════╝╚══██╔══╝██╔══██╗██║    ██╔══██╗██╔══██╗
changed: [localhost]
==> default: ██╔████╔██║█████╗    ██║  ███████║██║    ███████║██████╔╝
 
==> default: ██║╚██╔╝██║██╔══╝    ██║  ██╔══██║██║    ██╔══██║██╔══██╗
TASK: [syncdb] ****************************************************************
==> default: ██║ ╚═╝ ██║███████╗  ██║  ██║  ██║███████╗██║  ██║██████╔╝
changed: [localhost]
==> default: ╚═╝    ╚═╝╚══════╝  ╚═╝  ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚════╝
 
==> default:
TASK: [lineinfile dest=/home/vagrant/.bashrc line='cd /mos'] ******************
==> default: Vagrant VM Development Machine
changed: [localhost]
==> default:
 
==> default: How to proceed further:
PLAY RECAP ********************************************************************
==> default:
localhost                  : ok=7    changed=5    unreachable=0    failed=0
==> default: enter the VM with:
==> default: $ vagrant ssh
==> default:  
==> default: Execute the following commands inside the VM:
==> default:  
==> default: 1) You have to set the 'admin' superuser password manually
==> default: $ ./manage.py changepassword admin
==> default:  
==> default: 2) Start the server bound on all interfaces instead of 127.0.0.1 only
==> default: $ ./manage.py runserver 0.0.0.0:8000
==> default:
==> default: Access the instance under http://localhost:8000 in your browser
==> default:
==> default: Modifications in the folder will be immediately available in the dev environment.
==> default:
==> default:
</pre>
</pre>


Zeile 103: Zeile 175:
You should see something like:
You should see something like:
<pre>
<pre>
Linux debian-7 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64
Linux mos-dev-vm 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64


The programs included with the Debian GNU/Linux system are free software;
The programs included with the Debian GNU/Linux system are free software;
Zeile 111: Zeile 183:
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
permitted by applicable law.
Last login: Fri Feb 21 20:41:55 2014 from 10.0.2.2
Last login: Sun Dec 11 22:22:15 2022 from 10.0.2.2
vagrant@debian-7:/mos$  
(dev) vagrant@mos-dev-vm:/mos$  
</pre>
</pre>


'''Step 6: Set initial admin PW for your MOS (do this IN the ssh session you openend before in step 5)'''
'''Step 6: Set initial admin PW for your MOS (do this IN the ssh session you opened before as explained in step 5)'''


user "admin" is already created by the vagrant script.
user "admin" is already created by the vagrant script.


<pre>
<pre>
vagrant@debian-7:/mos$ ./manage.py changepassword admin
(dev) vagrant@mos-dev-vm:/mos$ ./manage.py changepassword admin
</pre>
</pre>
You will be asked twice for the new password
You will be asked twice for the new password
Zeile 128: Zeile 200:
'''Step 7: Run the MOS inside your VM'''
'''Step 7: Run the MOS inside your VM'''
<pre>
<pre>
vagrant@debian-7:/mos$ ./manage.py runserver 0.0.0.0:8000
(dev) vagrant@mos-dev-vm:/mos$ ./manage.py runserver 0.0.0.0:8000
</pre>
</pre>
You should see something like:
You should see something like:
<pre>
<pre>
Validating models...
Watching for file changes with StatReloader
Performing system checks...


0 errors found
System check identified no issues (0 silenced).
Februar 22, 2014 - 01:35:07
Dezember 11, 2022 - 23:22:39
Django version 1.5.5, using settings 'mos.settings.devel'
Django version 3.2.16, using settings 'mos.settings.devel'
Development server is running at http://0.0.0.0:8000/
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Quit the server with CONTROL-C.
</pre>
</pre>
Zeile 169: Zeile 242:
<pre>
<pre>
Bringing machine 'default' up with 'virtualbox' provider...
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
==> default: Checking if box 'debian/bullseye64' version '11.20220912.1' is up to date...
[default] Clearing any previously set network interfaces...
==> default: Clearing any previously set forwarded ports...
[default] Preparing network interfaces based on configuration...
==> default: Clearing any previously set network interfaces...
[default] Forwarding ports...
==> default: Preparing network interfaces based on configuration...
[default] -- 22 => 2222 (adapter 1)
    default: Adapter 1: nat
[default] -- 8000 => 8000 (adapter 1)
==> default: Forwarding ports...
[default] Booting VM...
    default: 8000 (guest) => 8000 (host) (adapter 1)
[default] Waiting for machine to boot. This may take a few minutes...
    default: 22 (guest) => 2222 (host) (adapter 1)
[default] Machine booted and ready!
==> default: Booting VM...
[default] The guest additions on this VM do not match the installed version of
==> default: Waiting for machine to boot. This may take a few minutes...
VirtualBox! In most cases this is fine, but in rare cases it can
    default: SSH address: 127.0.0.1:2222
prevent things such as shared folders from working properly. If you see
    default: SSH username: vagrant
shared folder errors, please make sure the guest additions within the
    default: SSH auth method: private key
virtual machine match the version of VirtualBox you have installed on
==> default: Machine booted and ready!
your host and reload your VM.
==> default: Checking for guest additions in VM...
 
    default: The guest additions on this VM do not match the installed version of
Guest Additions Version: 4.2.16
    default: VirtualBox! In most cases this is fine, but in rare cases it can
VirtualBox Version: 4.1
    default: prevent things such as shared folders from working properly. If you see
[default] Mounting shared folders...
    default: shared folder errors, please make sure the guest additions within the
[default] -- /vagrant
    default: virtual machine match the version of VirtualBox you have installed on
[default] VM already provisioned. Run `vagrant provision` or use `--provision` to force it
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 6.0.0 r127566
    default: VirtualBox Version: 7.0
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /vagrant => <YOUR LOCAL SHARED FOLDER PATH>
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
</pre>
</pre>
No worries, the last line is not an error :)
No worries, the last line is not an error :)

Aktuelle Version vom 11. Dezember 2022, 22:52 Uhr

MOS/VM

MOS VM
Mos vm.png
Gestartet: 21.01.2013
Involvierte: queltos, Hetti
Status: awesome
Beschreibung: Build your own virtual machine for MOS development using Vagrant
Shutdownprozedur:
Zuletzt aktualisiert: 2022-12-11


Build your own virtual machine for MOS development using Vagrant.

Done with:

  • Debian Bullseye (Debian 11)
  • Oracle VM VirtualBox Manager 6 and further
  • Vagrant 2.x.x


Checkout MOS from github

$ https://github.com/Metalab/mos.git

cd into the project directory

$ cd mos

Call vagrant to build and setup your VM

$ vagrant up

You should see something like

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'debian/bullseye64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'debian/bullseye64' version '11.20220912.1' is up to date...
==> default: Setting the name of the VM: mos_metalab_default_1670797153813_2335
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 8000 (guest) => 8000 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.0.0 r127566
    default: VirtualBox Version: 7.0
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /vagrant => <YOUR LOCAL SHARED FOLDER PATH>
==> default: Running provisioner: shell...
    default: Running: /tmp/vagrant-shell20221211-25251-r8t8xa.sh

#####
<various packet update operations>
#####

    default: 
    default: PLAY [all] *********************************************************************
    default: 
    default: TASK [Gathering Facts] *********************************************************
    default: ok: [localhost]
    default: 
    default: TASK [link /mos -> /vagrant] ***************************************************
    default: changed: [localhost]
    default: 
    default: TASK [Install packages] ********************************************************
    default: changed: [localhost]
    default: 
    default: TASK [add locale de_DE.UTF-8] **************************************************
    default: changed: [localhost]
    default: 
    default: TASK [Upgrade pip3] ************************************************************
    default: changed: [localhost]
    default: 
    default: TASK [Install python modules] **************************************************
    default: changed: [localhost] => (item=/vagrant/requirements.txt)
    default: changed: [localhost] => (item=/vagrant/requirements-dev.txt)
    default: 
    default: TASK [check the existence of the secret_key.py file and create one if it does not exist] ***
    default: ok: [localhost]
    default: 
    default: TASK [generate random django secret] *******************************************
    default: skipping: [localhost]
    default: 
    default: TASK [generate mos sqlite database] ********************************************
    default: ok: [localhost]
    default: 
    default: TASK [django makemigrations] ***************************************************
    default: ok: [localhost]
    default: 
    default: TASK [django migrate] **********************************************************
    default: ok: [localhost]
    default: 
    default: TASK [Create Admin User] *******************************************************
    default: skipping: [localhost]
    default: 
    default: TASK [django loaddata] *********************************************************
    default: skipping: [localhost]
    default: 
    default: TASK [Activate virtualenv on vagrant ssh] **************************************
    default: changed: [localhost]
    default: 
    default: TASK [Change into mos dir on vagrant ssh] **************************************
    default: changed: [localhost]
    default: 
    default: PLAY RECAP *********************************************************************
    default: localhost                  : ok=12   changed=7    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0

After booting up you will be greeted with our Info Screen with the next steps.

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default: 
==> default: ======================================================
==> default: 
==> default: 
==> default: ███╗   ███╗███████╗████████╗ █████╗ ██╗      █████╗ ██████╗
==> default: ████╗ ████║██╔════╝╚══██╔══╝██╔══██╗██║     ██╔══██╗██╔══██╗
==> default: ██╔████╔██║█████╗     ██║   ███████║██║     ███████║██████╔╝
==> default: ██║╚██╔╝██║██╔══╝     ██║   ██╔══██║██║     ██╔══██║██╔══██╗
==> default: ██║ ╚═╝ ██║███████╗   ██║   ██║  ██║███████╗██║  ██║██████╔╝
==> default: ╚═╝     ╚═╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚════╝
==> default: 
==> default: Vagrant VM Development Machine
==> default: 
==> default: How to proceed further:
==> default: 
==> default: enter the VM with:
==> default: $ vagrant ssh
==> default: 
==> default: Execute the following commands inside the VM:
==> default: 
==> default: 1) You have to set the 'admin' superuser password manually
==> default: $ ./manage.py changepassword admin
==> default: 
==> default: 2) Start the server bound on all interfaces instead of 127.0.0.1 only
==> default: $ ./manage.py runserver 0.0.0.0:8000
==> default: 
==> default: Access the instance under http://localhost:8000 in your browser
==> default: 
==> default: Modifications in the folder will be immediately available in the dev environment.
==> default: 
==> default: 

Step 5: Login into your VM

$ vagrant ssh

You should see something like:

Linux mos-dev-vm 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Dec 11 22:22:15 2022 from 10.0.2.2
(dev) vagrant@mos-dev-vm:/mos$ 

Step 6: Set initial admin PW for your MOS (do this IN the ssh session you opened before as explained in step 5)

user "admin" is already created by the vagrant script.

(dev) vagrant@mos-dev-vm:/mos$ ./manage.py changepassword admin

You will be asked twice for the new password

This user can be used to login into the MOS through the web frontend

Step 7: Run the MOS inside your VM

(dev) vagrant@mos-dev-vm:/mos$ ./manage.py runserver 0.0.0.0:8000

You should see something like:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Dezember 11, 2022 - 23:22:39
Django version 3.2.16, using settings 'mos.settings.devel'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

Step 8: Open a browser on your host machine and connect to http://localhost:8000/

Step 9: Login into MOS with a click on "Login" and provide the credentials used in step 6

Step 10: Profit!

Hint: After login into your VM you will be in the directory from your host where you checked out the project. You can edit files on your host and the changes will be visible inside your VM.

If you are done with hacking stop the VM from your host with

$ vagrant halt

or suspend it

$ vagrant suspend

To start it again just enter:

$ vagrant up

You will see something like:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'debian/bullseye64' version '11.20220912.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 8000 (guest) => 8000 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.0.0 r127566
    default: VirtualBox Version: 7.0
==> default: Setting hostname...
==> default: Mounting shared folders...
    default: /vagrant => <YOUR LOCAL SHARED FOLDER PATH>
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

No worries, the last line is not an error :)

btw, don't forget to login into it and start MOS again