Skip to content
Snippets Groups Projects

Replacement MR for defunct MR13

Merged Noe Nieto requested to merge noe.nieto/ldh_developer:master into master
3 files
+ 85
83
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 52
50
# The box command
# The box command
The `box` command is a small wrapper around Vagrant that allows you to manage virtual machines easily. Currently the supported providers are libvirt and Digital Ocean. For most commands you only need to provide the hostname.
The Shipwright's `box` command is a small wrapper around Vagrant that allows you to easily manage boxes eithar as virtual machines with `libvirt` or droplets with Digital Ocean. For most commands you only need to provide the hostname.
## How it works
## How it works
The `box` command uses `~/.config/ldh_developer/box/` as configuration directory.
The Shipwright's `box` command uses `~/.config/ldh_developer/box/` as configuration directory.
Every folder inside the `box` folder represents a box, so for a box with hostname `floyd` the `$VAGRANT_HOME` directory is `~/.config/lds_developer/box/floyd`:
Every folder inside the `box` folder contains the necessary configuration files; so for a box with hostname `floyd` the `$VAGRANT_HOME` directory is `~/.config/lds_developer/box/floyd`:
```bash
```bash
ls -l ~/.config/ldh_developer/box/
ls -l ~/.config/ldh_developer/box/
@@ -14,9 +14,9 @@ total 8
@@ -14,9 +14,9 @@ total 8
drwxr-xr-x 3 nnieto nnieto 4.0K Nov 27 21:46 floyd/
drwxr-xr-x 3 nnieto nnieto 4.0K Nov 27 21:46 floyd/
```
```
The `floyd` folder contains two files (`Vagrantfile` and `shim.yml`) and the vagrant hidden folder(`.vagrant`).
The `floyd` folder contains two files (`Vagrantfile` and `shim.yml`) and the vagrant hidden folder(`.vagrant`). This directory is also used to store more configuration files or support files if needed (i.e. Ansible).
Once `box` creates a box, you can manage it with the libvirt, digital ocean and vagrant tools of your choice. Recommended tools are:
Once `box` command finishes building the box, you can manage it with the tools of your choice. Recommended tools are:
- [GNOME Vagrant Indicator](https://github.com/fffilo/gnome-vagrant-indicator)
- [GNOME Vagrant Indicator](https://github.com/fffilo/gnome-vagrant-indicator)
- virt-manager (apt install virt-manager)
- virt-manager (apt install virt-manager)
@@ -25,38 +25,38 @@ Once `box` creates a box, you can manage it with the libvirt, digital ocean and
@@ -25,38 +25,38 @@ Once `box` creates a box, you can manage it with the libvirt, digital ocean and
`box` supports these commands:
`box` supports these commands:
- `status`: report the status of the virtual machines created/managed by `box`.
- `status`: report the status of the boxes created/managed by `shipwright`.
- `create`: create a new VM. You only need to provide the hostname.
- `create`: create a new box. You only need to provide the hostname.
- `up`: starts a VM.
- `up`: starts a box.
- `halt`: stops a VM.
- `halt`: stops a box.
- `destroy`: destroys the VM
- `destroy`: destroys the box
- `ssh`: opens a ssh session directly to the VM as `vagrant` user.
- `ssh`: opens a ssh session directly to the box as `vagrant` user.
- `playbook`: provisions a VM with an ansible playbook.
- `playbook`: provisions a box with an ansible playbook.
- `which`: prints the configuration directory path of a VM.
- `which`: prints the configuration directory path of a box.
- `open`: opens the configuration directory of a VM with the current file manager (nautilus, dolphin, etc.)
- `open`: opens the configuration directory of a box with the current file manager (nautilus, dolphin, etc.)
### The `status` command
### The `status` command
Prints a summary of the state of all VM's managed by `box`. Example:
Prints a summary of the state of all the boxes managed by `shipwright`. Example:
```
```
$ box status
$ shipwright box status
hostname State IP Address
hostname State IP Address
nina running 192.168.121.185
nina running 192.168.121.185
pinta shutoff <N/A>
pinta shutoff <N/A>
stmaria running 192.168.121.178
stmaria running 192.168.121.178
Total 3 machine(s)
Total 3 box(es)
$
$
```
```
### The `create` command
### The `create` command
This command creates a new VM. You only need to provide the hostname. But you can specify the ram size and the number of cpus.
This command creates a new box. You only need to provide the hostname. But you can also specify the ram size and the number of cpus.
The following example creates a VM with the hostname `usoland`. The default values for ram size is 512 MB, and 1 CPU.
The following example creates a box with the hostname `usoland`. The default values are libvirt as provider, ram size is 512 MB, and 1 CPU.
```
```
$ box create usoland
$ shipwright box create usoland
Bringing machine 'usoland' up with 'libvirt' provider...
Bringing machine 'usoland' up with 'libvirt' provider...
==> usoland: Checking if box 'debian/stretch64' is up to date...
==> usoland: Checking if box 'debian/stretch64' is up to date...
[...]
[...]
@@ -66,10 +66,11 @@ Bringing machine 'usoland' up with 'libvirt' provider...
@@ -66,10 +66,11 @@ Bringing machine 'usoland' up with 'libvirt' provider...
[...]
[...]
```
```
The following example creates a VM with the hostname `usoland` with 4 cpus and 1GB of ram:
 
The following example creates a box with the hostname `usoland` with 4 cpus and 1GB of ram:
```
```
$ box create usoland --cpus 4 --ram 1024
$ shipwright box create usoland --cpus 4 --ram 1024
Bringing machine 'usoland' up with 'libvirt' provider...
Bringing machine 'usoland' up with 'libvirt' provider...
[...]
[...]
==> usoland: -- Cpus: 4
==> usoland: -- Cpus: 4
@@ -83,12 +84,12 @@ Bringing machine 'usoland' up with 'libvirt' provider...
@@ -83,12 +84,12 @@ Bringing machine 'usoland' up with 'libvirt' provider...
$
$
```
```
**Note**: Vagrant/libvirt needs root access to create and modify networks on the machine. Vagrant will try to use sudo and will request your passowrd.
**Note**: Vagrant/libvirt needs root access to create and modify networks on the box. Vagrant will try to use sudo and will request your passowrd.
Finally the following example creates a box using Digital Ocean as provider.
Finally the following example creates a box using Digital Ocean as provider.
```
```
$ shipwright vm create starblade --provider digital_ocean --token 2f17c...808c50ae9
$ shipwright box create starblade --provider digital_ocean --token 2f17c...808c50ae9
Creating ssh key required by Vagrant's Digital Ocean plugin ...
Creating ssh key required by Vagrant's Digital Ocean plugin ...
Bringing machine 'starblade' up with 'digital_ocean' provider...
Bringing machine 'starblade' up with 'digital_ocean' provider...
@@ -105,42 +106,43 @@ Bringing machine 'starblade' up with 'digital_ocean' provider...
@@ -105,42 +106,43 @@ Bringing machine 'starblade' up with 'digital_ocean' provider...
**Known issue**: The create command freezes on this message: `==> starblade: Assigned IP address: ...` for some minutes before continuing to destroy the droplet. If you hit Ctrl-C shortly after the `.. Assigned IP adress [..]` messages, the droplet stays alive.
**Known issue**: The create command freezes on this message: `==> starblade: Assigned IP address: ...` for some minutes before continuing to destroy the droplet. If you hit Ctrl-C shortly after the `.. Assigned IP adress [..]` messages, the droplet stays alive.
**default provider**: The default provider is `libvirt`, you need to specify `--provider digital_ocean` and `--token` on the command line to spin the machine in Digital Ocean. If you don't have a token yet, you ca generate one on _Manage_ / _API_ section in your DO's control panel.
**default provider**: The default provider is `libvirt`, you need to specify `--provider digital_ocean` and `--token` on the command line to spin the droplet in Digital Ocean. If you don't have a token yet, you ca generate one on _Manage_ / _API_ section in your DO's control panel.
### The `up`, `halt` and `restart` commands
### The `up`, `halt` and `restart` commands
Use these commands to start, shutdown, or restart a box. As an example, the previous section we created one. If we check the status we find that it's running.
Use these commands to start, shutdown, or restart a box. As an example, the previous section we created one. If we check the status we find that it's running.
```
```bash
$ box status
$ shipwright box status
hostname State IP Address
hostname State IP Address
usoland running 192.168.121.57
usoland running 192.168.121.57
Total 1 machine(s)
Total 1 box(es)
$
$
```
```
Now, let's use the `halt` command.
Now, let's use the `halt` command.
```
```bash
box halt usoland
$ shipwright box halt usoland
==> usoland: Halting domain...
==> usoland: Halting domain...
$
$
```
```
We can see that the VM status is `shutoff`:
We can see that the box status is `shutoff`:
```
$ box status
```bash
 
$ shipwright box status
hostname State IP Address
hostname State IP Address
usoland shutoff <N/A>
usoland shutoff <N/A>
Total 1 machine(s)
Total 1 box(es)
$
$
```
```
We use the `up` command to start the VM again.
We use the `up` command to start the box again.
```
```bash
$ box up usoland
$ shipwright box up usoland
Bringing machine 'usoland' up with 'libvirt' provider...
Bringing machine 'usoland' up with 'libvirt' provider...
==> usoland: Checking if box 'debian/stretch64' is up to date...
==> usoland: Checking if box 'debian/stretch64' is up to date...
==> usoland: Starting domain.
==> usoland: Starting domain.
@@ -155,13 +157,13 @@ Bringing machine 'usoland' up with 'libvirt' provider...
@@ -155,13 +157,13 @@ Bringing machine 'usoland' up with 'libvirt' provider...
$
$
```
```
Now `status` shows that the vm is running.
Now `status` shows that the box is running.
```
```
$ box status
$ box status
hostname State IP Address
hostname State IP Address
usoland running 192.168.121.57
usoland running 192.168.121.57
Total 1 machine(s)
Total 1 box(es)
$
$
```
```
@@ -188,7 +190,7 @@ $
@@ -188,7 +190,7 @@ $
### The `ssh` command
### The `ssh` command
The ssh command opens an ssh to the VM.
The ssh command opens an ssh to the box.
```bash
```bash
$ box ssh usoland
$ box ssh usoland
@@ -209,7 +211,7 @@ $
@@ -209,7 +211,7 @@ $
### The `which` command
### The `which` command
The `which` command prints the full path to the `$VAGRANT_HOME` directory of the VM.
The `which` command prints the full path to the `$VAGRANT_HOME` directory of the box.
```
```
$ box which usoland
$ box which usoland
@@ -220,24 +222,24 @@ $
@@ -220,24 +222,24 @@ $
### The `open` command
### The `open` command
This command opens a new window of your file manager pointing to the `$VAGRANT_HOME` of the VM.
This command opens a new window of your file manager pointing to the `$VAGRANT_HOME` of the box.
```bash
```bash
./box open --hostname=starone0
shipwright open open --hostname=starone0
[... nautilis shows up ...]
[... nautilis shows up ...]
```
```
### The `ansible` command
### The `ansible` command
This command allows you to run an ansible playbook against one of the VMs. For example: I have two VM's managed by `box`:
This command allows you to run an ansible playbook against one of the boxess. For example: I have two oxes managed by `shipwright`:
```
```bash
./box status
$ shipwright box status
hostname State IP Address
hostname State IP Address
usoland shutoff <N/A>
usoland shutoff <N/A>
going-merry running 192.168.121.89
going-merry running 192.168.121.89
Total 2 machine(s)
Total 2 box(es)
```
```
Let's install rust on`going-merry`. The playbook looks like this:
Let's install rust on`going-merry`. The playbook looks like this:
@@ -255,7 +257,7 @@ Let's install rust on`going-merry`. The playbook looks like this:
@@ -255,7 +257,7 @@ Let's install rust on`going-merry`. The playbook looks like this:
Let's save it as `rust.yml` and run the playbook against `going-merry`:
Let's save it as `rust.yml` and run the playbook against `going-merry`:
```
```
./box playbook going-merry rust.yaml
shipwright playbook going-merry rust.yaml
PLAY [Rust Playbook] *************************************************************************************
PLAY [Rust Playbook] *************************************************************************************
@@ -270,10 +272,10 @@ going-merry : ok=2 changed=1 unreachable=0 failed=
@@ -270,10 +272,10 @@ going-merry : ok=2 changed=1 unreachable=0 failed=
```
```
Now I can use `rustc` on the VM:
Now I can use `rustc` inside the box:
```bash
```bash
./box ssh going-merry
shipwright ssh going-merry
Linux going-merry 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
Linux going-merry 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) 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;
Loading