Commit Graph

35 Commits

Author SHA1 Message Date
Manuel Mendez
549e540671 vagrant: Fix basebox having corrupt docker-compose binary
This fixes the vagrant based sandbox from not working. This was particularly
annoying to track down because of not having `set -x` in `setup.sh` but
what looks like xtrace output in stderr. The xtrace output on stderr
was actually from the `generate_certificates` container:

```
    provisioner: 2021/04/26 21:22:32 [INFO] signed certificate with serial number 142120228981443865252746731124927082232998754394
    provisioner: + cat
    provisioner:  server.pem
    provisioner:  ca.pem
    provisioner: + cmp
    provisioner:  -s
    provisioner:  bundle.pem.tmp
    provisioner:  bundle.pem
    provisioner: + mv
    provisioner:  bundle.pem.tmp
    provisioner:  bundle.pem
    provisioner: Error: No such object:
==> provisioner: Clearing any previously set forwarded ports...
==> provisioner: Removing domain...
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
```
I ended up doubting the `if ! cmp` blocks until I added `set -euxo pipefail` and
the issue was pretty obviously in docker-compose land.

```
$ vagrant destroy -f; vagrant up provisioner
==> worker: Domain is not created. Please run `vagrant up` first.
==> provisioner: Domain is not created. Please run `vagrant up` first.
Bringing machine 'provisioner' up with 'libvirt' provider...
==> provisioner: Checking if box 'tinkerbelloss/sandbox-ubuntu1804' version '0.1.0' is up to date...
==> provisioner: Creating image (snapshot of base box volume).
==> provisioner: Creating domain with the following settings...
...
    provisioner: 2021/04/27 18:20:13 [INFO] signed certificate with serial number 138080403356863347716407921665793913032297783787
    provisioner: + cat server.pem ca.pem
    provisioner: + cmp -s bundle.pem.tmp bundle.pem
    provisioner: + mv bundle.pem.tmp bundle.pem
    provisioner: + local certs_dir=/etc/docker/certs.d/192.168.1.1
    provisioner: + cmp --quiet /vagrant/deploy/state/certs/ca.pem /vagrant/deploy/state/webroot/workflow/ca.pem
    provisioner: + cp /vagrant/deploy/state/certs/ca.pem /vagrant/deploy/state/webroot/workflow/ca.pem
    provisioner: + cmp --quiet /vagrant/deploy/state/certs/ca.pem /etc/docker/certs.d/192.168.1.1/tinkerbell.crt
    provisioner: + [[ -d /etc/docker/certs.d/192.168.1.1/ ]]
    provisioner: + cp /vagrant/deploy/state/certs/ca.pem /etc/docker/certs.d/192.168.1.1/tinkerbell.crt
    provisioner: + setup_docker_registry
    provisioner: + local registry_images=/vagrant/deploy/state/registry
    provisioner: + [[ -d /vagrant/deploy/state/registry ]]
    provisioner: + mkdir -p /vagrant/deploy/state/registry
    provisioner: + start_registry
    provisioner: + docker-compose -f /vagrant/deploy/docker-compose.yml up --build -d registry
    provisioner: + check_container_status registry
    provisioner: + local container_name=registry
    provisioner: + local container_id
    provisioner: ++ docker-compose -f /vagrant/deploy/docker-compose.yml ps -q registry
    provisioner: + container_id=
    provisioner: + local start_moment
    provisioner: + local current_status
    provisioner: ++ docker inspect '' --format '{{ .State.StartedAt }}'
    provisioner: Error: No such object:
    provisioner: + start_moment=
    provisioner: + finish
    provisioner: + rm -rf /tmp/tmp.ve3XJ7qtgA
```

Notice that `container_id` is empty. This turns out to be because
`docker-compose` is an empty file!

```
vagrant@provisioner:/vagrant/deploy$ docker-compose up --build registry
vagrant@provisioner:/vagrant/deploy$ which docker-compose
/usr/local/bin/docker-compose
vagrant@provisioner:/vagrant/deploy$ docker-compose -h
vagrant@provisioner:/vagrant/deploy$ file /usr/local/bin/docker-compose
/usr/local/bin/docker-compose: empty
```

So with the following test patch:

```diff
diff --git a/deploy/vagrant/scripts/tinkerbell.sh b/deploy/vagrant/scripts/tinkerbell.sh
index 915f27f..dcb379c 100644
--- a/deploy/vagrant/scripts/tinkerbell.sh
+++ b/deploy/vagrant/scripts/tinkerbell.sh
@@ -34,6 +34,14 @@ setup_nat() (
 main() (
 	export DEBIAN_FRONTEND=noninteractive

+	local name=docker-compose-$(uname -s)-$(uname -m)
+	local url=https://github.com/docker/compose/releases/download/1.26.0/$name
+	curl -fsSLO "$url"
+	curl -fsSLO "$url.sha256"
+	sha256sum -c <"$name.sha256"
+	chmod +x "$name"
+	sudo mv "$name" /usr/local/bin/docker-compose
+
 	if ! [[ -f ./.env ]]; then
 		./generate-env.sh eth1 >.env
 	fi
```

We can try again and we're back to a working state:

```
$ vagrant destroy -f; vagrant up provisioner
==> worker: Domain is not created. Please run `vagrant up` first.
==> provisioner: Domain is not created. Please run `vagrant up` first.
Bringing machine 'provisioner' up with 'libvirt' provider...
==> provisioner: Checking if box 'tinkerbelloss/sandbox-ubuntu1804' version '0.1.0' is up to date...
==> provisioner: Creating image (snapshot of base box volume).
==> provisioner: Creating domain with the following settings...
...
    provisioner: + setup_docker_registry
    provisioner: + local registry_images=/vagrant/deploy/state/registry
    provisioner: + [[ -d /vagrant/deploy/state/registry ]]
    provisioner: + mkdir -p /vagrant/deploy/state/registry
    provisioner: + start_registry
    provisioner: + docker-compose -f /vagrant/deploy/docker-compose.yml up --build -d registry
    provisioner: Creating network "deploy_default" with the default driver
    provisioner: Creating volume "deploy_postgres_data" with default driver
    provisioner: Building registry
    provisioner: Step 1/7 : FROM registry:2.7.1
...
    provisioner: Successfully tagged deploy_registry:latest
    provisioner: Creating deploy_registry_1 ...
Creating deploy_registry_1 ... done
    provisioner: + check_container_status registry
    provisioner: + local container_name=registry
    provisioner: + local container_id
    provisioner: ++ docker-compose -f /vagrant/deploy/docker-compose.yml ps -q registry
    provisioner: + container_id=2e3d9557fd4c0d7f7e1c091b957a0033d23ebb93f6c8e5cdfeb8947b2812845c
...
    provisioner: + sudo -iu vagrant docker login --username=admin --password-stdin 192.168.1.1
    provisioner: WARNING! Your password will be stored unencrypted in /home/vagrant/.docker/config.json.
    provisioner: Configure a credential helper to remove this warning. See
    provisioner: https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    provisioner: Login Succeeded
    provisioner: + set +x
    provisioner: NEXT:  1. Enter /vagrant/deploy and run: source ../.env; docker-compose up -d
    provisioner:        2. Try executing your fist workflow.
    provisioner:           Follow the steps described in https://tinkerbell.org/examples/hello-world/ to say 'Hello World!' with a workflow.
```

:toot:

Except that my results are not due to the way docker-compose is being installed
at all. After still running into this issue when using a box built with the new
install method I was still seeing empty docker-compose files. I ran a bunch of
experiments to try and figure out what is going on. The issue is strictly
in vagrant-libvirt since vagrant-virtualbox works fine. Turns out data isn't
being flushed back to disk at shutdown. Both calling `sync` or writing multiple
copies of the binary to the fs (3x at least) ended up working. Then I was informed
of a known vagrant-libvirt issue which matches this behavior, https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1013!

Fixes #59

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2021-04-28 19:54:35 +00:00
Manuel Mendez
4a59c96463 vagrant: Ensure the whats_next message is printed at the end
The tinkerbell.sh script ends up doing some other work after
calling setup.sh and has set -x enabled so the whats_next message
is likely to be missed. So now save it for later reading as the last
thing done.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2021-04-27 20:05:49 +00:00
Manuel Mendez
5eceec91ed box: make lists be multiline and with same line ending
Better for adding/removing things this way.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2021-04-27 20:05:49 +00:00
Manuel Mendez
0fff3e6d7f sh: Make use of bashisms in bash scripts
Both [[ ]] and (( )) bashisms are better than the alternative
in POSIX sh, since they are builtin and don't suffer from quoting
or number-of-args issues.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2021-04-27 20:04:38 +00:00
Manuel Mendez
88bf5771ea vagrant: Use source instead of . for better grepability.
Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2021-04-27 20:04:38 +00:00
Gaurav Gahlot
c40086d221
rename generate-envrc to generate-env
Signed-off-by: Gaurav Gahlot <gauravgahlot0107@gmail.com>
2021-04-16 22:21:10 +05:30
Nahum Shalman
4d13239d77 Fix NAT to reference correct interfaces
This moves the NAT commands from terraform to setup.sh

Signed-off-by: Nahum Shalman <nshalman@equinix.com>
2021-04-08 16:17:38 +00:00
Jason DeTiberus
8cde1e811d
pin boots to TINKERBELL_HOST_IP instead of 0.0.0.0 2021-03-19 15:38:04 -04:00
mergify[bot]
319d5a56b1
Merge branch 'master' into captee 2021-03-19 07:54:25 +00:00
Jason DeTiberus
21bc78b77d
Add support for a nat-less libvirt deployment and multiple workers 2021-03-18 09:45:57 -04:00
Moath Qasim
0a5a491530 remove the metadata filter in the sandbox
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
2021-03-16 19:36:40 +01:00
Moath Qasim
20d0a92e01 add current_versions.sh file to the terraform provisioner
Signed-off-by: Moath Qasim <moad.qassem@gmail.com>

Signed-off-by: Moath Qasim <moad.qassem@gmail.com>
2021-03-03 19:23:19 +01:00
Gianluca Arbezzano
1ac6fdf827 Fix port collision between boots and nginx
I am not sure when it happens, it can be when we removed the NGINX_IP,
or when we checked that every services were using ports OR network_mode
but we exposed nginx and boots over the same port.

This commit fixes that.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2021-03-03 09:34:18 +01:00
Joseph D. Marhee
cf57ac7c6a Removes conflicting composefile network instruction per #53 for boots container definition
Signed-off-by: Joseph D. Marhee <jmarhee@interiorae.com>
2021-02-17 15:20:22 -06:00
mergify[bot]
7315975878
Merge branch 'master' into metal-provider-update-plan 2021-02-09 17:50:28 +00:00
Joseph D. Marhee
21301d182f Updates variable description to use EM
Signed-off-by: Joseph D. Marhee <jmarhee@interiorae.com>
2021-02-04 13:54:31 -06:00
Joseph D. Marhee
cbd90e063e Updates plan to use Metal provider, updates outputs accordingly
Signed-off-by: Joseph D. Marhee <jmarhee@interiorae.com>
2021-02-04 13:54:31 -06:00
Gaurav Gahlot
cf67fe6476
nit pick 2021-02-04 15:22:23 +05:30
Gianluca Arbezzano
9edecbfc86 Bootstrap Packer template for libvirt and Vbox
Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2021-02-04 10:27:19 +01:00
mergify[bot]
141083e24d
Merge branch 'master' into single-ip-address 2021-01-27 10:38:39 +00:00
Michael Richard
c7b84264af Set NGINX to bind on TINKERBELL_HOST_IP:8080
Signed-off-by: Michael Richard <michael.richard.ing@gmail.com>
2021-01-25 15:19:23 -05:00
Jason DeTiberus
6150dd91c7
Fix vagrant config for libvirt 2021-01-25 15:00:02 -05:00
Gianluca Arbezzano
e4d8fafa33 Fix shfmt for tinkerbell.sh file
Not sure how I happened but it looks like we introduced an shfmt error
in master

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2021-01-25 19:06:31 +01:00
Gianluca Arbezzano
243777b6ef Fix NAT and make it working for Terraform and Vagrant
Commit b504810 introduced a NAT to make worker capable of reaching the
public internet via the provisioner.

But it also introduced a bug, it only works for the Vagrant setup as
Manny pointed out:

https://github.com/tinkerbell/sandbox/pull/33#issuecomment-759651035

This is an attempt to fix it

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2021-01-22 16:40:08 +01:00
Gaurav Gahlot
9dc63fbdb6
happy terraform fmt
Signed-off-by: Gaurav Gahlot <gauravgahlot0107@gmail.com>
2021-01-12 12:28:06 +05:30
Gaurav Gahlot
60270f3164
add missing version constraints for providers - null, template
Signed-off-by: Gaurav Gahlot <gauravgahlot0107@gmail.com>
2021-01-12 12:10:17 +05:30
Gianluca Arbezzano
22f6f22012 Cleanup not required cleanup sql script
Since we introduced migration the init file is not required and it is a
leftover.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2020-12-10 14:42:24 +01:00
Gianluca Arbezzano
1c4f829252 Bump tinkerbell stack to newest versions
Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2020-11-12 17:12:42 +01:00
Manuel Mendez
731f9563fd Ensure all files pass ci-non-go.sh checks.
Signed-off-by: Manuel Mendez <mmendez@equinix.com>
2020-11-09 17:39:00 -05:00
mergify[bot]
72bf833702
Merge branch 'master' into feature/single-version-place 2020-09-28 16:41:16 +00:00
James W. Brinkerhoff
adfccfb1b0 Vagrant virtualbox worker env override fixes
* Change ENV var check to only validate the existence of the
  var in the local env
* Add VAGRANT_WORKER_SCALE env variable override to control
  GUI scaling for virtualbox

Signed-off-by: James W. Brinkerhoff <jwb@paravolve.net>
2020-09-23 07:40:38 -04:00
Gianluca Arbezzano
0c4f4d6f59 Single place for all the tink stack version
Tinkerbell is made of different components as we all know at this point.

Sandbox had those versions all over the places. This PR moves them as
part of the `envrc` file.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2020-09-21 17:50:08 +02:00
Gianluca Arbezzano
bd63279e59 this is the right version of the terraform code
I copied a wrong version of the terraform code.

Sorry

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2020-09-10 16:42:00 +02:00
Gianluca Arbezzano
680e9bea98 New home for terraform setup (cp from tink repo)
This is coming from the tink repo.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
2020-09-10 16:04:48 +02:00
Gianluca Arbezzano
6ede8cb2e3 initial commit 2020-08-20 13:53:27 +02:00