-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setup.sh: simplify #147
Merged
Merged
setup.sh: simplify #147
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
59a6560
setup.sh: don't install software automatically
grahamc b912b6e
generate-envrc: make its own, trivial, shell script
grahamc 8927d3e
setup.sh: drop cidr variable, unused
grahamc a004489
setup.sh: shellcheck SC2230: which is non-standard. Use builtin 'comm…
grahamc ae3c070
setup.sh: shellcheck SC2086: Double quote to prevent globbing and wor…
grahamc 72f233c
setup.sh: shellcheck SC2181: Check exit code directly with e.g. 'if m…
grahamc 6bfa17a
setup.sh: shellcheck sc1090/sc1091: don't follow sources
grahamc f2461fd
setup.sh: is_network_configured: clean up the logic ladder
grahamc 4ec1a78
setup.sh: setup_networking: back out early if network is setup already
grahamc 8f28f15
setup.sh: network: try less hard to configure the network
grahamc da08044
setup: pass system version to setup_network
grahamc 45c295c
networking: stub out netplan support
grahamc f2bc924
networking: implement netplan further
grahamc 3a03682
networking: centos: try harder to configure the networking (see: the …
grahamc 8cc73e3
generate-envrc: emit a CIDR addr too
grahamc 1f6434f
setup: configure network forwarding on ubuntu and centos
grahamc 1496e60
setup: do per-distro branch in the network setup only
grahamc 9e15085
setup: osie: move the webroot in to under deploy/
grahamc 75f0429
setup: use env to find bash
grahamc cb03feb
setup: use DEPLOYDIR instead of recalculating / sharing $deploy
grahamc 9a1077f
setup: use (..) to reduce scope leak between function calls
grahamc 5abc4ea
setup: certs: generate once and not part of docker-compose
grahamc 494e063
jq: add
grahamc be3e278
docker-compose: store the registry in the deploy dir
grahamc ec1c97c
generate-envrc: properly quote variables in the output
grahamc 86abd9e
setup.sh: fixup jq expression in creating CSRs
grahamc f9c2174
setup.sh: docker-registry start: abstract mirroring images
grahamc d897d03
registry: add curl for healthchecks with a custom TLS cert
grahamc 2a4c6af
check_containter_status: use healthcheck events
grahamc 9d60e44
tinkerbell crt: only copy if it has changed; on error, ask the user t…
grahamc 2bb0aaf
ubuntu 17.10 check: use jq instead of depending on bc
grahamc 8bb6faf
setup network: only require ifup / ifdown if our network strategy req…
grahamc 661f03b
tls certs: UID/GID -> id -g
grahamc c08db6c
setup: encourage the user to run docker-compose up on their own
grahamc 3518507
run with -u
grahamc da3cc16
lsb_dist: tr in the function
grahamc 4ff438d
Use DEPLOYDIR instead of pwd/deploy
grahamc 5e1dec4
setup: put state in its own directory, away from the repo's contents
grahamc ffa901a
fluentbit config: mount read-only
grahamc eafab24
envrc: ditch BROADCAST, NETMASK calcualtion
grahamc 08bbd9d
{generate-envrc,setup}.sh: handle incompatible terminals
grahamc df0d63a
setup: run the cert generation process each time
grahamc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
FROM registry:2 | ||
RUN apk add --no-cache --update curl | ||
ARG REGISTRY_USERNAME | ||
ARG REGISTRY_PASSWORD | ||
RUN mkdir -p /certs /auth | ||
RUN htpasswd -Bbn ${REGISTRY_USERNAME} ${REGISTRY_PASSWORD} > /auth/htpasswd | ||
EXPOSE 443 | ||
EXPOSE 443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env sh | ||
|
||
if ! { [[ -r ca.json ]] && [[ -r ca.pem ]] && [[ -r ca-key.pem ]]; }; then | ||
sed "s|@FACILITY@|$FACILITY|g" <ca.in.json >ca.json | ||
set -eux | ||
|
||
cd /certs | ||
|
||
if [ ! -f ca-key.pem ]; then | ||
cfssl gencert \ | ||
-initca ca.json | cfssljson -bare ca | ||
rm -f server-csr.json server-*.pem | ||
fi | ||
if ! { [[ -r server-csr.json ]] && [[ -r server.pem ]] && [[ -r server-key.pem ]]; }; then | ||
sed "s|@FACILITY@|$FACILITY|g" <server-csr.in.json >server-csr.json | ||
|
||
if [ ! -f server.pem ]; then | ||
cfssl gencert \ | ||
-ca=ca.pem \ | ||
-ca-key=ca-key.pem \ | ||
-config=ca-config.json \ | ||
-config=/ca-config.json \ | ||
-profile=server \ | ||
server-csr.json | cfssljson -bare server | ||
cat server.pem ca.pem | tee bundle.pem | ||
server-csr.json | | ||
cfssljson -bare server | ||
fi | ||
|
||
cat server.pem ca.pem >bundle.pem.tmp | ||
|
||
# only "modify" the file if truly necessary since workflow will serve it with | ||
# modtime info for client caching purposes | ||
cat server.pem ca.pem >bundle.pem.tmp | ||
if ! cmp -s bundle.pem.tmp bundle.pem; then | ||
mv bundle.pem.tmp bundle.pem | ||
else | ||
rm bundle.pem.tmp | ||
fi | ||
|
||
mv *.pem certs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"CN": "tinkerbell", | ||
"hosts": [ | ||
"tinkerbell.@[email protected]", | ||
"tinkerbell.registry", | ||
"tinkerbell.tinkerbell", | ||
"tinkerbell", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
|
||
# stops the execution if a command or pipeline has an error | ||
set -eu | ||
|
||
if command -v tput >/dev/null && tput setaf 1 >/dev/null 2>&1; then | ||
# color codes | ||
RED="$(tput setaf 1)" | ||
RESET="$(tput sgr0)" | ||
fi | ||
|
||
ERR="${RED:-}ERROR:${RESET:-}" | ||
|
||
err() ( | ||
if [ -z "${1:-}" ]; then | ||
cat >&2 | ||
else | ||
echo "$ERR " "$@" >&2 | ||
fi | ||
) | ||
|
||
candidate_interfaces() ( | ||
ip -o link show | | ||
awk -F': ' '{print $2}' | | ||
sed 's/[ \t].*//;/^\(lo\|bond0\|\|\)$/d' | | ||
sort | ||
) | ||
|
||
validate_tinkerbell_network_interface() ( | ||
local tink_interface=$1 | ||
|
||
if ! candidate_interfaces | grep -q "^$tink_interface$"; then | ||
err "Invalid interface ($tink_interface) selected, must be one of:" | ||
candidate_interfaces | err | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
) | ||
|
||
generate_password() ( | ||
head -c 12 /dev/urandom | sha256sum | cut -d' ' -f1 | ||
) | ||
|
||
generate_envrc() ( | ||
local tink_interface=$1 | ||
|
||
validate_tinkerbell_network_interface "$tink_interface" | ||
|
||
local registry_password | ||
registry_password=$(generate_password) | ||
cat <<EOF | ||
# Network interface for Tinkerbell's network | ||
export TINKERBELL_NETWORK_INTERFACE="$tink_interface" | ||
|
||
# Decide on a subnet for provisioning. Tinkerbell should "own" this | ||
# network space. Its subnet should be just large enough to be able | ||
# to provision your hardware. | ||
export TINKERBELL_CIDR=29 | ||
|
||
# Host IP is used by provisioner to expose different services such as | ||
# tink, boots, etc. | ||
# | ||
# The host IP should the first IP in the range, and the Nginx IP | ||
# should be the second address. | ||
export TINKERBELL_HOST_IP=192.168.1.1 | ||
|
||
# NGINX IP is used by provisioner to serve files required for iPXE boot | ||
export TINKERBELL_NGINX_IP=192.168.1.2 | ||
|
||
# Docker Registry's username and password | ||
export TINKERBELL_REGISTRY_USERNAME=admin | ||
export TINKERBELL_REGISTRY_PASSWORD="$registry_password" | ||
|
||
# Legacy options, to be deleted: | ||
export FACILITY=onprem | ||
export ROLLBAR_TOKEN=ignored | ||
export ROLLBAR_DISABLE=1 | ||
EOF | ||
) | ||
|
||
main() ( | ||
if [ -z "${1:-}" ]; then | ||
err "Usage: $0 network-interface-name > envrc" | ||
exit 1 | ||
fi | ||
|
||
generate_envrc "$1" | ||
) | ||
|
||
main "$@" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
cat <<-EOF
to avoid indent changes. But for follow up PR is fine.