Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
74b5a4d5
Commit
74b5a4d5
authored
Mar 02, 2020
by
Erik Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ubuntu to vagrant provision
parent
4370fc14
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
36 deletions
+64
-36
Vagrantfile
Vagrantfile
+8
-14
vagrant
scripts/provision/generic/alpine310/vagrant
+2
-5
vagrant
scripts/provision/generic/centos7/vagrant
+1
-3
vagrant
scripts/provision/generic/ubuntu1804/vagrant
+26
-0
vagrant
scripts/provision/vagrant
+27
-14
No files found.
Vagrantfile
View file @
74b5a4d5
OS
=
(
ENV
[
'OS'
]
||
"alpine310"
)
OS
=
(
ENV
[
'OS'
]
||
"alpine310"
)
BOX_REPO
=
(
ENV
[
'BOX_REPO'
]
||
"generic"
)
BOX_REPO
=
(
ENV
[
'BOX_REPO'
]
||
"generic"
)
BOX
=
(
ENV
[
'BOX'
]
||
"
#{
BOX_REPO
}
/
#{
OS
}
"
)
HOME
=
File
.
dirname
(
__FILE__
)
HOME
=
File
.
dirname
(
__FILE__
)
PROJECT
=
File
.
basename
(
HOME
)
PROJECT
=
File
.
basename
(
HOME
)
NUM_NODES
=
(
ENV
[
'NUM_NODES'
]
||
0
).
to_i
NUM_NODES
=
(
ENV
[
'NUM_NODES'
]
||
0
).
to_i
...
@@ -16,7 +15,11 @@ MOUNT_TYPE = ENV['MOUNT_TYPE'] || "nfs"
...
@@ -16,7 +15,11 @@ MOUNT_TYPE = ENV['MOUNT_TYPE'] || "nfs"
# %admin ALL = (root) NOPASSWD: /sbin/nfsd restart
# %admin ALL = (root) NOPASSWD: /sbin/nfsd restart
# --- May need to add terminal to System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
# --- May need to add terminal to System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
def
provision
(
vm
)
def
provision
(
vm
,
node_num
)
node_os
=
(
ENV
[
"OS_
#{
node_num
}
"
]
||
OS
)
vm
.
box
=
(
ENV
[
"BOX_
#{
node_num
}
"
]
||
ENV
[
"BOX"
]
||
"
#{
BOX_REPO
}
/
#{
node_os
}
"
)
vm
.
hostname
=
"
#{
PROJECT
}
-
#{
node_num
}
-
#{
node_os
}
"
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.
#{
100
+
node_num
}
"
vm
.
provision
"shell"
,
vm
.
provision
"shell"
,
path:
VAGRANT_PROVISION
,
path:
VAGRANT_PROVISION
,
env:
{
'HOME'
=>
HOME
,
'GOPATH'
=>
ENV
[
'GOPATH'
],
'BOX'
=>
vm
.
box
}
env:
{
'HOME'
=>
HOME
,
'GOPATH'
=>
ENV
[
'GOPATH'
],
'BOX'
=>
vm
.
box
}
...
@@ -29,26 +32,17 @@ Vagrant.configure("2") do |config|
...
@@ -29,26 +32,17 @@ Vagrant.configure("2") do |config|
v
.
memory
=
NODE_MEMORY
v
.
memory
=
NODE_MEMORY
v
.
customize
[
"modifyvm"
,
:id
,
"--audio"
,
"none"
]
v
.
customize
[
"modifyvm"
,
:id
,
"--audio"
,
"none"
]
end
end
config
.
vm
.
box
=
BOX
config
.
vm
.
hostname
=
PROJECT
config
.
vm
.
synced_folder
"."
,
HOME
,
type:
MOUNT_TYPE
if
Vagrant
.
has_plugin?
(
"vagrant-timezone"
)
if
Vagrant
.
has_plugin?
(
"vagrant-timezone"
)
config
.
timezone
.
value
=
:host
config
.
timezone
.
value
=
:host
end
end
config
.
vm
.
synced_folder
"."
,
HOME
,
type:
MOUNT_TYPE
if
NUM_NODES
==
0
if
NUM_NODES
==
0
config
.
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.100"
provision
(
config
.
vm
,
0
)
provision
(
config
.
vm
)
else
else
(
1
..
NUM_NODES
).
each
do
|
i
|
(
1
..
NUM_NODES
).
each
do
|
i
|
config
.
vm
.
define
".
#{
i
}
"
do
|
node
|
config
.
vm
.
define
".
#{
i
}
"
do
|
node
|
node_os
=
(
ENV
[
"OS_
#{
i
}
"
]
||
OS
)
provision
(
node
.
vm
,
i
)
node
.
vm
.
box
=
(
ENV
[
"BOX_
#{
i
}
"
]
||
"
#{
BOX_REPO
}
/
#{
node_os
}
"
)
node
.
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.
#{
100
+
i
}
"
node
.
vm
.
hostname
=
"
#{
PROJECT
}
-
#{
i
}
"
provision
(
node
.
vm
)
end
end
end
end
end
end
...
...
scripts/provision/generic/alpine310/vagrant
View file @
74b5a4d5
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
set
-ve
set
-ve
apk add
-q
-f
curl libc6-compat tzdata
apk add
-q
-f
curl libc6-compat tzdata
echo
"Installing go
$goversion
"
download_go
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
download_dqlite
# ---
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
export SELINUX=true
...
@@ -12,9 +12,6 @@ export STATIC_BUILD=true
...
@@ -12,9 +12,6 @@ export STATIC_BUILD=true
EOF
EOF
.
/etc/profile.d/build.sh
.
/etc/profile.d/build.sh
# ---
# ---
echo
"Downloading DQLITE from
$DQLITE_URL
"
curl
-sfL
$DQLITE_URL
-o
/usr/src/dqlite.tgz
# ---
.
/tmp/docker-run
.
/tmp/docker-run
# ---
# ---
go get
-u
github.com/go-delve/delve/cmd/dlv
go get
-u
github.com/go-delve/delve/cmd/dlv
...
...
scripts/provision/generic/centos7/vagrant
View file @
74b5a4d5
#!/bin/bash
#!/bin/bash
set
-ve
set
-ve
download_go
echo
"Installing go
$goversion
"
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
# ---
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
export SELINUX=true
...
...
scripts/provision/generic/ubuntu1804/vagrant
0 → 100755
View file @
74b5a4d5
#!/bin/bash
set
-ve
download_go
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
# export DQLITE=true
# export STATIC_BUILD=true
EOF
.
/etc/profile.d/build.sh
# ---
apt-get
install
-y
\
build-essential
\
pkg-config
\
libseccomp-dev
\
libsqlite3-dev
\
libselinux1-dev
\
zlib1g-dev
\
# ---
sed
-E
's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add|apt-get install -y|g'
-i
/tmp/docker-run
.
/tmp/docker-run
# ---
go get
-u
github.com/go-delve/delve/cmd/dlv
# ---
scripts/provision/vagrant
View file @
74b5a4d5
#!/bin/bash
#!/bin/bash
set
-ve
set
-ve
ARCH
=
amd64
PROVISION
=
"scripts/provision/
$BOX
/vagrant"
PROVISION
=
"scripts/provision/
$BOX
/vagrant"
OS
=
$(
basename
$BOX
)
if
[
!
-f
/etc/vagrant_box_build_time
]
;
then
if
[
!
-f
/etc/vagrant_box_build_time
]
;
then
echo
"This script should only be called during vagrant provisioning"
echo
"This script should only be called during vagrant provisioning"
...
@@ -28,15 +26,10 @@ if [ -z "${GOPATH}" ]; then
...
@@ -28,15 +26,10 @@ if [ -z "${GOPATH}" ]; then
else
else
echo
"Using parent GOPATH=
$GOPATH
"
echo
"Using parent GOPATH=
$GOPATH
"
fi
fi
goversion
=
$(
grep
"^FROM "
Dockerfile.dapper |
sed
-e
's/^FROM golang:\(.*\)-.*/\1/'
)
if
[
-z
"
$goversion
"
]
;
then
echo
"Cannot find version of go to fetch"
exit
1
fi
# --- Setup basic env
# --- Setup basic env
cat
<<
EOF
>/etc/profile.d/env.sh
cat
<<
EOF
>/etc/profile.d/env.sh
export ARCH=amd64
export GO111MODULE=off
export GO111MODULE=off
export GOPATH="
$GOPATH
"
export GOPATH="
$GOPATH
"
export PATH=/usr/local/bin:
$PATH
:/usr/local/go/bin:
$GOPATH
/bin
export PATH=/usr/local/bin:
$PATH
:/usr/local/go/bin:
$GOPATH
/bin
...
@@ -44,10 +37,6 @@ export HOME="$HOME" && cd
...
@@ -44,10 +37,6 @@ export HOME="$HOME" && cd
EOF
EOF
.
/etc/profile.d/env.sh
.
/etc/profile.d/env.sh
# --- Setup for dqlite download
DQLITE_URL
=
"https://github.com/
$(
grep
dqlite-build Dockerfile.dapper |
sed
-e
's/^.*--from=\([^ ]*\).*$/\1/'
-e
's|:|/releases/download/|'
)
/dqlite-
$ARCH
.tgz"
mkdir
-p
/usr/src/
# --- Clean go cache
# --- Clean go cache
rm
-rf
.cache/go-build
||
true
rm
-rf
.cache/go-build
||
true
...
@@ -55,13 +44,13 @@ rm -rf .cache/go-build || true
...
@@ -55,13 +44,13 @@ rm -rf .cache/go-build || true
sed
-i
's|:/bin/ash$|:/bin/bash|g'
/etc/passwd
sed
-i
's|:/bin/ash$|:/bin/bash|g'
/etc/passwd
cat
<<
EOF
>/etc/profile.d/color.sh
cat
<<
EOF
>/etc/profile.d/color.sh
alias ls='ls --color=auto'
alias ls='ls --color=auto'
export PS1='\033[31m[ \033[90m\D{%F %T}\033[31m ]
\033[35m{\033[90m
$OS
\033[35m}
\n\[\033[36m\]\u\[\033[m\]🐮\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\
$
'
export PS1='\033[31m[ \033[90m\D{%F %T}\033[31m ]\n\[\033[36m\]\u\[\033[m\]🐮\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\
$
'
EOF
EOF
# --- Setup install script from docker run commands
# --- Setup install script from docker run commands
mkdir
-p
${
GOPATH
}
/bin
mkdir
-p
${
GOPATH
}
/bin
mkdir
-p
/go
mkdir
-p
/go
ln
-s
$GOPATH
/bin /go/bin
ln
-s
f
$GOPATH
/bin /go/bin
sed
':a;N;$!ba;s/\\\n/ /g'
<Dockerfile.dapper |
grep
'^RUN '
|
sed
-e
's/^RUN //'
>
/tmp/docker-run
sed
':a;N;$!ba;s/\\\n/ /g'
<Dockerfile.dapper |
grep
'^RUN '
|
sed
-e
's/^RUN //'
>
/tmp/docker-run
export
BINDIR
=
/go/bin
export
BINDIR
=
/go/bin
export
GOPATH
=
/go
export
GOPATH
=
/go
...
@@ -79,6 +68,30 @@ cat <<\EOF >/etc/motd
...
@@ -79,6 +68,30 @@ cat <<\EOF >/etc/motd
EOF
EOF
# --- Utility function to download go
download_go
()
{
goversion
=
$(
grep
"^FROM "
Dockerfile.dapper |
sed
-e
's/^FROM golang:\(.*\)-.*/\1/'
)
if
[
-z
"
$goversion
"
]
;
then
echo
"Cannot find version of go to fetch"
return
1
fi
echo
"Installing go
$goversion
"
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
}
# --- Utility function to download dqlite
download_dqlite
()
{
dqliteURL
=
"https://github.com/
$(
grep
dqlite-build Dockerfile.dapper |
sed
-e
's/^.*--from=\([^ ]*\).*$/\1/'
-e
's|:|/releases/download/|'
)
/dqlite-
$ARCH
.tgz"
if
[
-z
"
$dqliteURL
"
]
;
then
echo
"Cannot find dqlite URL to fetch"
return
1
fi
mkdir
-p
/usr/src/
echo
"Downloading DQLITE from
$dqliteURL
"
curl
-sfL
$dqliteURL
-o
/usr/src/dqlite.tgz
}
# --- Run vagrant provision script if available
# --- Run vagrant provision script if available
if
[
!
-f
"
${
PROVISION
}
"
]
;
then
if
[
!
-f
"
${
PROVISION
}
"
]
;
then
echo
'WARNING: Unable to execute provision script "${PROVISION}"'
echo
'WARNING: Unable to execute provision script "${PROVISION}"'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment