зеркало из https://github.com/Azure/Avere.git
update install instructions and jumpbox build to use go modules (#1276)
This commit is contained in:
Родитель
f466050522
Коммит
3d3fb8d6ed
|
@ -24,22 +24,31 @@ These instructions work on Centos 7 (systemd) and Ubuntu 18.04. This can be ins
|
|||
2. If not already installed go, install golang:
|
||||
|
||||
```bash
|
||||
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
|
||||
tar xvf go1.11.2.linux-amd64.tar.gz
|
||||
sudo chown -R root:root ./go
|
||||
sudo mv go /usr/local
|
||||
mkdir ~/gopath
|
||||
echo "export GOPATH=$HOME/gopath" >> ~/.profile
|
||||
echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> ~/.profile
|
||||
GO_DL_FILE=go1.16.6.linux-amd64.tar.gz
|
||||
wget --tries=12 --wait=5 https://dl.google.com/go/$GO_DL_FILE
|
||||
sudo tar -C /usr/local -xzf $GO_DL_FILE
|
||||
rm -f $GO_DL_FILE
|
||||
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
|
||||
source ~/.profile
|
||||
rm go1.11.2.linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
2. setup CacheWarmer code
|
||||
```bash
|
||||
# checkout CacheWarmer code, all dependencies and build the binaries
|
||||
cd $GOPATH
|
||||
go get -v github.com/Azure/Avere/src/go/...
|
||||
# checkout and build CacheWarmer
|
||||
cd
|
||||
RELEASE_DIR=~/release
|
||||
mkdir -p $RELEASE_DIR
|
||||
git clone https://github.com/Azure/Avere.git
|
||||
# build the cache warmer
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-jobsubmitter
|
||||
go build
|
||||
mv cachewarmer-jobsubmitter $RELEASE_DIR/.
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-manager
|
||||
go build
|
||||
mv cachewarmer-manager $RELEASE_DIR/.
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-worker
|
||||
go build
|
||||
mv cachewarmer-worker $RELEASE_DIR/.
|
||||
```
|
||||
|
||||
### Mount NFS and build a bootstrap directory
|
||||
|
|
|
@ -25,46 +25,64 @@ function retrycmd_if_failure() {
|
|||
}
|
||||
|
||||
function update_linux() {
|
||||
retrycmd_if_failure 12 5 yum -y install wget unzip git nfs-utils tmux nc
|
||||
retrycmd_if_failure 12 5 yum -y install wget unzip git nfs-utils tmux nc jq
|
||||
retrycmd_if_failure 12 5 yum -y install epel-release
|
||||
retrycmd_if_failure 12 5 yum -y install python-pip
|
||||
#retrycmd_if_failure 3 5 pip install hstk
|
||||
}
|
||||
|
||||
function install_golang() {
|
||||
cd $AZURE_HOME_DIR/.
|
||||
GO_DL_FILE=go1.14.4.linux-amd64.tar.gz
|
||||
retrycmd_if_failure 12 5 wget https://dl.google.com/go/$GO_DL_FILE
|
||||
tar xvf $GO_DL_FILE
|
||||
chown -R $ADMIN_USER_NAME:$ADMIN_USER_NAME ./go
|
||||
mkdir -p $AZURE_HOME_DIR/gopath
|
||||
chown -R $ADMIN_USER_NAME:$ADMIN_USER_NAME $AZURE_HOME_DIR/gopath
|
||||
echo "export GOPATH=$AZURE_HOME_DIR/gopath" >> $AZURE_HOME_DIR/.bashrc
|
||||
echo "export PATH=\$GOPATH/bin:$AZURE_HOME_DIR/go/bin:$PATH" >> $AZURE_HOME_DIR/.bashrc
|
||||
echo "export GOROOT=$AZURE_HOME_DIR/go" >> $AZURE_HOME_DIR/.bashrc
|
||||
rm $GO_DL_FILE
|
||||
cd $AZURE_HOME_DIR
|
||||
GO_DL_FILE=go1.16.6.linux-amd64.tar.gz
|
||||
wget --tries=12 --wait=5 https://dl.google.com/go/$GO_DL_FILE
|
||||
sudo tar -C /usr/local -xzf $GO_DL_FILE
|
||||
rm -f $GO_DL_FILE
|
||||
#echo "export GOPATH=$AZURE_HOME_DIR/gopath" >> $AZURE_HOME_DIR/.profile
|
||||
echo "export PATH=$PATH:/usr/local/go/bin" >> $AZURE_HOME_DIR/.profile
|
||||
}
|
||||
|
||||
function pull_avere_github() {
|
||||
# best effort to build the github content
|
||||
set +e
|
||||
# setup the environment
|
||||
source $AZURE_HOME_DIR/.bashrc
|
||||
# use workaround set home for go to work, bug here: https://github.com/golang/go/issues/43938
|
||||
OLD_HOME=$HOME
|
||||
export HOME=$AZURE_HOME_DIR
|
||||
# checkout Checkpoint simulator code, all dependencies and build the binaries
|
||||
cd $GOPATH
|
||||
go get -v github.com/Azure/Avere/src/terraform/providers/terraform-provider-avere
|
||||
cd src/github.com/Azure/Avere/src/terraform/providers/terraform-provider-avere
|
||||
go mod download
|
||||
go mod tidy
|
||||
|
||||
# best effort to build the github content
|
||||
set +e
|
||||
RELEASE_DIR=$AZURE_HOME_DIR/releases
|
||||
mkdir -p $RELEASE_DIR
|
||||
source $AZURE_HOME_DIR/.profile
|
||||
cd $AZURE_HOME_DIR
|
||||
git clone https://github.com/Azure/Avere.git
|
||||
|
||||
# build the provider
|
||||
cd $AZURE_HOME_DIR/Avere/src/terraform/providers/terraform-provider-avere
|
||||
go build
|
||||
# build windows
|
||||
GOOS=windows GOARCH=amd64 go build
|
||||
mv terraform-provider-avere* $RELEASE_DIR/.
|
||||
|
||||
# build the cachewarmer
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-jobsubmitter
|
||||
go build
|
||||
mv cachewarmer-jobsubmitter $RELEASE_DIR/.
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-manager
|
||||
go build
|
||||
mv cachewarmer-manager $RELEASE_DIR/.
|
||||
cd $AZURE_HOME_DIR/Avere/src/go/cmd/cachewarmer/cachewarmer-worker
|
||||
go build
|
||||
mv cachewarmer-worker $RELEASE_DIR/.
|
||||
|
||||
cd $RELEASE_DIR/.
|
||||
ls -lh
|
||||
|
||||
# install provider
|
||||
version=$(curl -s https://api.github.com/repos/Azure/Avere/releases/latest | jq -r .tag_name | sed -e 's/[^0-9]*\([0-9].*\)$/\1/')
|
||||
echo $version
|
||||
mkdir -p $AZURE_HOME_DIR/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64
|
||||
cp terraform-provider-avere $AZURE_HOME_DIR/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64
|
||||
cp $RELEASE_DIR/terraform-provider-avere $AZURE_HOME_DIR/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64
|
||||
|
||||
# restore HOME
|
||||
export HOME=$OLD_HOME
|
||||
|
||||
# re-enable exit on error
|
||||
set -e
|
||||
}
|
||||
|
@ -82,9 +100,9 @@ gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azu
|
|||
|
||||
function install_terraform() {
|
||||
cd $AZURE_HOME_DIR/.
|
||||
retrycmd_if_failure 12 5 wget https://releases.hashicorp.com/terraform/0.15.0/terraform_0.15.0_linux_amd64.zip
|
||||
unzip terraform_0.15.0_linux_amd64.zip -d /usr/local/bin
|
||||
rm terraform_0.15.0_linux_amd64.zip
|
||||
wget --tries=12 --wait=5 https://releases.hashicorp.com/terraform/1.0.2/terraform_1.0.2_linux_amd64.zip
|
||||
unzip terraform_1.0.2_linux_amd64.zip -d /usr/local/bin
|
||||
rm terraform_1.0.2_linux_amd64.zip
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
|
|
@ -341,41 +341,42 @@ _Note_: The provider is built as a go module - this lets you build outside your
|
|||
|
||||
The following build instructions work in https://shell.azure.com, Centos, or Ubuntu:
|
||||
|
||||
1. if this is centos, install git
|
||||
1. if this is centos, install git and jq
|
||||
|
||||
```bash
|
||||
sudo yum install git
|
||||
sudo yum install -y git jq
|
||||
```
|
||||
|
||||
2. If not already installed go, install golang:
|
||||
1. if this is ubuntu, install jq
|
||||
|
||||
```bash
|
||||
wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz
|
||||
tar xvf go1.14.linux-amd64.tar.gz
|
||||
mkdir ~/gopath
|
||||
echo "export GOPATH=$HOME/gopath" >> ~/.profile
|
||||
echo "export PATH=\$GOPATH/bin:$HOME/go/bin:$PATH" >> ~/.profile
|
||||
echo "export GOROOT=$HOME/go" >> ~/.profile
|
||||
sudo apt get install -y jq
|
||||
```
|
||||
|
||||
1. If not already installed go, install golang:
|
||||
|
||||
```bash
|
||||
GO_DL_FILE=go1.16.6.linux-amd64.tar.gz
|
||||
wget --tries=12 --wait=5 https://dl.google.com/go/$GO_DL_FILE
|
||||
sudo tar -C /usr/local -xzf $GO_DL_FILE
|
||||
rm -f $GO_DL_FILE
|
||||
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
|
||||
source ~/.profile
|
||||
rm go1.14.linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
3. build the provider code
|
||||
1. build and install the provider code
|
||||
```bash
|
||||
# checkout Checkpoint simulator code, all dependencies and build the binaries
|
||||
cd $GOPATH
|
||||
go get -v github.com/Azure/Avere/src/terraform/providers/terraform-provider-avere
|
||||
cd src/github.com/Azure/Avere/src/terraform/providers/terraform-provider-avere
|
||||
go mod download
|
||||
go mod tidy
|
||||
cd
|
||||
git clone https://github.com/Azure/Avere.git
|
||||
# build the cache warmer
|
||||
cd $AZURE_HOME_DIR/Avere/src/terraform/providers/terraform-provider-avere
|
||||
go build
|
||||
# install the avere provider
|
||||
version=$(curl -s https://api.github.com/repos/Azure/Avere/releases/latest | jq -r .tag_name | sed -e 's/[^0-9]*\([0-9].*\)$/\1/')
|
||||
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64
|
||||
cp terraform-provider-avere ~/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64
|
||||
```
|
||||
|
||||
4. Install the provider `~/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64/terraform-provider-avere` to the ~/.terraform.d/plugins/registry.terraform.io/hashicorp/avere/$version/linux_amd64 directory of your terraform environment, where $version is the version of the provider.
|
||||
|
||||
# Build the Terraform Provider binary on Windows
|
||||
|
||||
Here are the instructions for building the windows binary:
|
||||
|
@ -387,13 +388,25 @@ Here are the instructions for building the windows binary:
|
|||
1. open a new powershell command prompt and type the following to checkout the code:
|
||||
|
||||
```powershell
|
||||
mkdir $env:GOPATH -Force
|
||||
cd $env:GOPATH
|
||||
go get -v github.com/Azure/Avere/src/terraform/providers/terraform-provider-avere
|
||||
cd $env:GOPATH\src\github.com\Azure\Avere\src\terraform\providers\terraform-provider-avere
|
||||
go mod download
|
||||
go mod tidy
|
||||
# change to your desired directory
|
||||
$env:SRC='c:\src'
|
||||
mkdir $env:SRC -Force
|
||||
cd $env:SRC
|
||||
git clone https://github.com/Azure/Avere.git
|
||||
cd $env:SRC\Avere\src\terraform\providers\terraform-provider-avere
|
||||
go build
|
||||
# install the provider
|
||||
# get the latest download URL
|
||||
$latestPage = Invoke-WebRequest https://api.github.com/repos/Azure/Avere/releases/latest
|
||||
($latestpage.Content|ConvertFrom-Json|Select tag_name).tag_name -match '[^0-9]*([0-9\.].*)$'
|
||||
$version = $matches[1]
|
||||
$browserDownloadUrl = (($latestpage.Content |ConvertFrom-Json|Select assets).assets |where-object {$_.browser_download_url -match ".exe"}).browser_download_url
|
||||
|
||||
# download the provider
|
||||
$pluginsDirectory = "$Env:APPDATA\terraform.d\plugins\registry.terraform.io\hashicorp\avere\$version\windows_amd64"
|
||||
md $pluginsDirectory -ea 0
|
||||
$pluginPath = "$pluginsDirectory\terraform-provider-avere_v$version.exe"
|
||||
Write-Output "copying the avere plugin to $pluginPath"
|
||||
copy terraform-provider-avere.exe $pluginPath
|
||||
```
|
||||
|
||||
1. copy the .exe to the source directory
|
||||
|
|
Загрузка…
Ссылка в новой задаче