Commit 052ce3cc authored by Noe Nieto's avatar Noe Nieto 💬

Merge hopefully

parent c33cf44c
*.sublime-*
*.retry
*~
.vscode/
#! /bin/sh
exec $HOME/.local/ldh_developer/box/command "$@"
#! /bin/sh
exec $HOME/.local/ldh_developer/shipyard/shipyard "$@"
......@@ -6,9 +6,10 @@ mkdir --parents $HOME/.config/ldh_developer/playbooks
rm --recursive --force $HOME/.local/ldh_developer
rm --force $HOME/.local/bin/shipwright
ln --symbolic --force $PWD $HOME/.local/ldh_developer
rm -f $HOME/.local/ldh_developer && ln --symbolic $PWD $HOME/.local/ldh_developer
ln --symbolic --force $PWD/shipwright $HOME/.local/bin/shipwright
ln --symbolic --force $PWD/playbooks $HOME/.config/ldh_developer/playbooks/ldh_developer
rm -f $HOME/.config/ldh_developer/playbooks/ldh_developer && ln --symbolic $PWD/playbooks $HOME/.config/ldh_developer/playbooks/ldh_developer
shipwright update dependencies
# The shipyard
# The box command
The `shipyard` is a small wrapper around vagrant and libvirt that allows you to manage virtual machines easily. For most commands you only need to provide the hostname.
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.
## How it works
Shipyard uses `~/.config/ldh_developer/shipyard` as configuration directory.
Every folder inside the `shipyard` folder represents a vagrant box, so for a box with hostname `floyd` the `$VAGRANT_HOME` directory is `~/.config/lds_developer/shipyard/floyd`:
The `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`:
```bash
ls -l ~/.config/ldh_developer/shipyard/
ls -l ~/.config/ldh_developer/box/
total 8
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`).
Once `shipyard` creates a box, you can manage it with the libvirt and vagrant tools of your choice. Recommended tools are:
Once `box` creates a box, you can manage it with the libvirt, digital ocean and vagrant tools of your choice. Recommended tools are:
- [GNOME Vagrant Indicator](https://github.com/fffilo/gnome-vagrant-indicator)
- virt-manager (apt install virt-manager)
## Commands
`shipyard` supports these commands:
`box` supports these commands:
- `status`: report the status of the virtual machines created/managed by `shipyard`.
- `status`: report the status of the virtual machines created/managed by `box`.
- `create`: create a new VM. You only need to provide the hostname.
- `up`: starts a VM.
- `halt`: stops a VM.
......@@ -37,11 +37,10 @@ Once `shipyard` creates a box, you can manage it with the libvirt and vagrant to
### The `status` command
Prints a summary of the state of all VM's managed by `shipyard`. Example:
Prints a summary of the state of all VM's managed by `box`. Example:
```
$ shipyard status
$ box status
hostname State IP Address
nina running 192.168.121.185
pinta shutoff <N/A>
......@@ -57,7 +56,7 @@ This command creates a new VM. You only need to provide the hostname. But you ca
The following example creates a VM with the hostname `usoland`. The default values for ram size is 512 MB, and 1 CPU.
```
$ shipyard create usoland
$ box create usoland
Bringing machine 'usoland' up with 'libvirt' provider...
==> usoland: Checking if box 'debian/stretch64' is up to date...
[...]
......@@ -70,7 +69,7 @@ Bringing machine 'usoland' up with 'libvirt' provider...
The following example creates a VM with the hostname `usoland` with 4 cpus and 1GB of ram:
```
$ shipyard create usoland --cpus 4 --ram 1024
$ box create usoland --cpus 4 --ram 1024
Bringing machine 'usoland' up with 'libvirt' provider...
[...]
==> usoland: -- Cpus: 4
......@@ -84,15 +83,36 @@ Bringing machine 'usoland' up with 'libvirt' provider...
$
```
**Note**: Vagrant/libvirt need 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 machine. Vagrant will try to use sudo and will request your passowrd.
Finally the following example creates a box using Digital Ocean as provider.
```
$ shipwright vm create starblade --provider digital_ocean --token 2f17c...808c50ae9
Creating ssh key required by Vagrant's Digital Ocean plugin ...
Bringing machine 'starblade' up with 'digital_ocean' provider...
==> starblade: Using existing SSH key: Vagrant
==> starblade: Creating a new droplet...
==> starblade: Assigned IP address: 104.248.176.67
[...]
Bringing machine 'starblade' up with 'digital_ocean' provider...
==> starblade: Creating new SSH key: Vagrant...
==> starblade: Creating a new droplet...
==> starblade: Assigned IP address: 178.128.79.235
[...]
```
**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.
### The `up`, `halt` and `restart` commands
Use these commands to start and shutdown, or restart the VM's. As an example, the previous section we created one vm. 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.
```
$ shipyard status
$ box status
hostname State IP Address
usoland running 192.168.121.57
Total 1 machine(s)
......@@ -102,14 +122,14 @@ $
Now, let's use the `halt` command.
```
shipyard halt usoland
box halt usoland
==> usoland: Halting domain...
$
```
We can see that the VM status is `shutoff`:
```
$ shipyard status
$ box status
hostname State IP Address
usoland shutoff <N/A>
Total 1 machine(s)
......@@ -120,7 +140,7 @@ $
We use the `up` command to start the VM again.
```
$ shipyard up usoland
$ box up usoland
Bringing machine 'usoland' up with 'libvirt' provider...
==> usoland: Checking if box 'debian/stretch64' is up to date...
==> usoland: Starting domain.
......@@ -138,7 +158,7 @@ $
Now `status` shows that the vm is running.
```
$ shipyard status
$ box status
hostname State IP Address
usoland running 192.168.121.57
Total 1 machine(s)
......@@ -149,7 +169,7 @@ $
Now, `restart` is very straightforward.
```
$ shipyard restart starblade
$ box restart starblade
==> starblade: Halting domain...
Bringing machine 'starblade' up with 'libvirt' provider...
==> starblade: Checking if box 'debian/stretch64' is up to date...
......@@ -171,7 +191,7 @@ $
The ssh command opens an ssh to the VM.
```bash
$ shipyard ssh usoland
$ box ssh usoland
Linux usoland 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;
......@@ -192,8 +212,8 @@ $
The `which` command prints the full path to the `$VAGRANT_HOME` directory of the VM.
```
$ shipyard which usoland
/home/nnieto/.config/ldh_developer/shipyard/usoland
$ box which usoland
/home/nnieto/.config/ldh_developer/box/usoland
$
```
......@@ -203,17 +223,17 @@ $
This command opens a new window of your file manager pointing to the `$VAGRANT_HOME` of the VM.
```bash
./shipyard open --hostname=starone0
./box open --hostname=starone0
[... nautilis shows up ...]
```
### 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 `shipyard`:
This command allows you to run an ansible playbook against one of the VMs. For example: I have two VM's managed by `box`:
```
./shipyard status
./box status
hostname State IP Address
usoland shutoff <N/A>
going-merry running 192.168.121.89
......@@ -235,7 +255,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`:
```
./shipyard playbook going-merry rust.yaml
./box playbook going-merry rust.yaml
PLAY [Rust Playbook] *************************************************************************************
......@@ -253,7 +273,7 @@ going-merry : ok=2 changed=1 unreachable=0 failed=
Now I can use `rustc` on the VM:
```bash
./shipyard ssh going-merry
./box ssh going-merry
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;
......
This diff is collapsed.
Vagrant.configure("2") do |config|
config.vm.hostname = '{hostname}'
config.vm.define '{hostname}' do |config|
config.vm.provider :digital_ocean do |provider, override|
override.ssh.private_key_path = '~/.ssh/shipwright/id_rsa'
override.vm.box = 'digital_ocean'
override.vm.box_url = "https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box"
override.nfs.functional = false
provider.ssh_key_name = 'Shipwright-{username}'
provider.token = '{do_token}'
provider.image = "debian-9-x64"
provider.region = 'sfo2'
provider.size = '512mb'
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "shim.yml"
end
end
end
Vagrant.configure("2") do |config|
config.vm.hostname = "{hostname}"
config.vm.define :{hostname} do |{hostname}|
{hostname}.vm.box = "debian/stretch64"
{hostname}.vm.hostname = "{hostname}"
{hostname}.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.memory = "{ram}"
libvirt.username = "root"
libvirt.graphics_type = "spice"
libvirt.cpus = {cpus}
end
{hostname}.vm.provision "ansible" do |ansible|
ansible.playbook = "shim.yml"
end
end
end
\ No newline at end of file
......@@ -86,6 +86,9 @@
activate: true
- name: jwt-authentication-for-wp-rest-api
activate: true
- name: ldh-wp-username-policy
activate: true
url: https://source.puri.sm/liberty/ldh_wp_username_policy/-/archive/master/ldh_wp_username_policy-master.zip
users: {}
options:
- name: woocommerce_api_enabled
......
#! /bin/sh
exec $HOME/.local/ldh_developer/bin/"$@"
LDH_BIN=$HOME/.local/ldh_developer/bin/
if [ $# -eq 0 ] ; then
$LDH_BIN/list
else
if [ -x $LDH_BIN/"$1" ]; then
exec $LDH_BIN/"$@"
else
echo "Command $1 does not exist!\n"
$LDH_BIN/list
fi
fi
......@@ -14,7 +14,7 @@ sudo apt install \
python3-dev \
sshoot \
vagrant \
vagrant-libvirt \
vagrant-libvirt vagrant-digitalocean \
virt-manager \
xclip \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment