Skip to content
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

Fix vagrant #37

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
afc0636
switch to golang ssh crypto library
Oct 4, 2016
41d8221
Use glide for dependency management
Oct 4, 2016
ca95139
Add travis-ci
Dec 21, 2015
bfca52b
add glide to travis build
Oct 4, 2016
6180d7e
Use go get for glide
Oct 4, 2016
300a950
change from leonidlm to watson-platform import paths
Oct 4, 2016
197be4b
Merge pull request #3 from watson-platform/cml/goget
Oct 4, 2016
d8ac3c1
Allow PrivateNetworkOnlyFlag option
Feb 2, 2016
6013318
Merge pull request #4 from arunsure/privateNetwork
Oct 5, 2016
cbd6cee
Added github release config (#5)
Oct 11, 2016
20dd3fe
Add option for multiple disks & Cleanup extraneous files (#6)
Oct 12, 2016
5633822
added a condition to skip metadata device from image capturing
Aug 25, 2017
596f402
increasing test dealine to 2mins
Oct 5, 2017
a8ac822
Add Makefile for local dev
Oct 16, 2017
86b595a
Update to Go 1.9 in travis build
Oct 16, 2017
f76cf02
Switch to dep from glide
Oct 16, 2017
393fdab
Merge pull request #15 from watson-platform/cml/updatego
cmluciano Oct 16, 2017
da9d752
Merge pull request #14 from puneetloya/skip_metadata
cmluciano Oct 24, 2017
705485e
update README.md for dep
Feb 14, 2018
64d9dc1
Merge pull request #16 from teejaded/update_readme_for_dep
cmluciano Mar 7, 2018
371ef04
fix ancient Vagrantfile
david-shepard Mar 29, 2018
58641ef
fixed Vagrantfile
david-shepard Mar 30, 2018
86293d2
finally fixed the Vagrantfile
david-shepard Mar 30, 2018
f456697
make sure vagrant is the owner of $GOPATH
david-shepard Mar 30, 2018
ae8046b
fixed a ton of imports
david-shepard Mar 30, 2018
61ac859
remove glide reference and fix gox import
david-shepard Mar 30, 2018
82e4aef
fix gox import
Mar 30, 2018
19e4cf4
test without /vendor dir
Mar 30, 2018
ba0e5ea
increment go version to 1.9.2
Mar 30, 2018
1e48240
added necessary ssh arg
david-shepard Apr 2, 2018
bc1705c
add a necessary ssh arg
david-shepard Apr 2, 2018
be38d4b
attempt to fix deps
david-shepard Apr 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
example.json
crash.log
packer-builder-softlayer

/vendor/

# The following was created by https://www.gitignore.io

Expand Down
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
language: go
go:
- 1.9.2
- tip
cache:
directories:
- "$HOME/.glide"
install:
- ./script/bootstrap -u
script:
- ./script/test
env:
global:
- RELEASE_NAME=packer-builder-softlayer
before_deploy:
- ./script/build all
- sha256sum ${RELEASE_NAME}_* > checksums.sha256
deploy:
provider: releases
api_key:
secure: i4Q45DjcQ2e8idcLyDwj2gKZx08Cya+uXl2KHU1UWfqIl5O1036l7VQFJENyTz9s0zUEEg74o2z+1rSDWvpEV+nu4IROV1BHp1Xm7FNM/zUeutUGf4Eiqh830kchsGittoHkXo/kXcGnhWwWrRh3MYaw5zVPVrKb7MjpGQrQGUi2o7cI6Rbm6iOHIh8/D1T71okH4GDb9UoC4q25jh2rjWeF11wwZ/iGAe5YcY/Ae1fIwlzX7IMAcoNpxxoNIJSHIW11KXDiHWKtm7cL8mhNTgcFyEY9emIejLloYmONaCcOaqYq/ClMfLAXFOC1LuBw+2+4YGuAWcfWpQ3p6OuQ+DYN7tauuye/Wvh5E9Jg6zdmTEnZlnmy+rE+k/Rfc1MomH4LwmD80WjeAM/LZiSalGBo6BRPi31YtYC1hEuZJswCl9qHYjAlvpFcE/i2altNgx1EWVD7LmYSF0BcTH4TAySgWOewv8B26gcJDoos95zik7/phGD5WDV6FxFPuDJW+d7M6/DnZ7i9Bz5QJmfNp1DZ45qBLVGxg+WMk/QJsChFlLkZFH1HlklsoKAshoZ+JzDRGNVmf8uogsDd1NEBsaWe4a+2TqSTYEhVuUjsKqpAlFRbZL+fjpS9SXE5XCypDvbA75qC+BFFUi+st7/XbVOnn8cUdK80mk8+ebbbrCA=
file:
- checksums.sha256
- ${RELEASE_NAME}_darwin_amd64
- ${RELEASE_NAME}_linux_amd64
on:
tags: true



126 changes: 126 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/hashicorp/packer"
version = "1.2.2"

[[constraint]]
name = "github.com/watson-platform/packer-builder-softlayer"
version = "1.0.1"

[[constraint]]
branch = "master"
name = "golang.org/x/crypto"

[prune]
go-tests = true
unused-packages = true
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SHELL := /bin/bash
VERSION ?= $(shell git describe --tags --always --dirty)
RELEASE_NAME := packer-builder-softlayer

bootstrap:
./script/bootstrap

.PHONY: build
build:
export RELEASE_NAME=packer-builder-softlayer; ./script/build

.PHONY: test
test:
./script/test
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SoftLayer Builder (for packer.io)

[![Build Status](https://travis-ci.org/watson-platform/packer-builder-softlayer.svg?branch=master)](https://travis-ci.org/watson-platform/packer-builder-softlayer)

The softlayer builder is able to create new images for use with SoftLayer. The builder takes a source image (identified by it's global ID or reference name), runs any provisioning necessary on the image after launching it, then snapshots it into a reusable image. This reusable image can then be used as the foundation of new servers that are launched within SoftLayer.

The builder does not manage images. Once it creates an image, it is up to you to use it or delete it.
Expand All @@ -8,10 +10,13 @@ The builder does not manage images. Once it creates an image, it is up to you to

Download the Packer binaries [here](https://www.packer.io/downloads.html) or build Packer from source as described [here](https://github.com/mitchellh/packer#developing-packer).

Next, clone this repository into `$GOPATH/src/github.com/leonidlm/packer-builder-softlayer`. Then build the packer-softlayer-builder binary into the same folder as the packer binaries:
Install [dep](https://github.com/golang/dep#installation)

Next, clone this repository into `$GOPATH/src/github.com/watson-platform/packer-builder-softlayer`. Then build the packer-softlayer-builder binary into the same folder as the packer binaries:

```
cd $GOPATH/src/github.com/leonidlm/packer-builder-softlayer
cd $GOPATH/src/github.com/watson-platform/packer-builder-softlayer
dep ensure
go build -o /usr/local/packer/packer-builder-softlayer main.go
```

Expand Down Expand Up @@ -89,11 +94,13 @@ The reference of available configuration options is listed below.
* `instance_cpu` (string) - The amount of CPUs assigned to the instance. Defaults to 1
* `instance_memory` (string) - The amount of Memory (in bytes) assigned to the instance. Defaults to 1024
* `instance_network_speed` (string) - The network uplink speed, in megabits per second, which will be assigned to the instance. Defaults to 10
* `instance_disk_capacity` (string) - The amount of Disk capacity (in gigabytes) assigned to the instance. Defaults to 25
* `instance_disk_capacites` ([]int) - Array of disk capacities (in GB) corresponding to disk indexes (ie. [25,100] provisions disk 0 with 25 GB and disk 1 with 100 GB). Default: one disk with 25 GB
* `ssh_port` (string) - The port that SSH will be available on. Defaults to port 22
* `ssh_timeout` (string) - The time to wait for SSH to become available before timing out. The format of this value is a duration such as "5s" or "5m". The default SSH timeout is "1m". Defaults to "15m"
* `ssh_private_key_file` (string) - Use this ssh private key file instead of a generated ssh key pair for connecting to the instance.
* `instance_state_timeout` (string) - The time to wait, as a duration string, for an instance or image snapshot to enter a desired state (such as "active") before timing out. The default state timeout is "25m"
* `private_network_only_flag` (bool) - Specifies whether or not the instance only has access to the private network. When true this flag specifies that a compute instance is to only have access to the private network. Defaults to false.


As already stated above, a good way of reviewing the available options is by inspecting the output of the following API call:

Expand All @@ -104,7 +111,7 @@ As already stated above, a good way of reviewing the available options is by ins
## Contribute

New contributors are always welcome!
When in doubt please feel free to ask questions, just [Create an issue](https://github.com/leonidlm/packer-builder-softlayer/issues/new) with your enquiries.
When in doubt please feel free to ask questions, just [Create an issue](https://github.com/watson-platform/packer-builder-softlayer/issues/new) with your enquiries.

### Development Environment

Expand All @@ -117,4 +124,3 @@ To run the unit tests, execute "go test ./..." from the root project directory.
* Configure travis CI or any alternative to automatically test and build the code
* Provide an easier way to install (with no need to compile from source)
* Add an option to configure multiple disks for the instance

76 changes: 47 additions & 29 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Original version of this file copied from: https://raw.githubusercontent.com/mitchellh/packer/master/Vagrantfile
# Original version of this file copied from: https://raw.githubusercontent.com/hashicorp/packer/master/Vagrantfile
#

# VM Specifications
Expand All @@ -10,61 +10,79 @@ VM_GUI=false

GOROOT = '/opt/go'
GOPATH = '/opt/gopath'
PACKAGE_PATH = 'src/github.com/leonidlm/packer-builder-softlayer'
PACKAGE_PATH = 'src/github.com/watson-platform/packer-builder-softlayer'
GO_VERSION = '1.9.2'

script = <<SCRIPT
set -x

SRCROOT="#{GOROOT}"

# Install Go
sudo apt-get update
sudo apt-get install -y build-essential mercurial
sudo hg clone -u release https://code.google.com/p/go $SRCROOT
cd ${SRCROOT}/src
sudo ./all.bash

# Setup the GOPATH
sudo mkdir -p #{GOPATH}
cat <<EOF >/tmp/gopath.sh

download="https://storage.googleapis.com/golang/go#{GO_VERSION}.linux-amd64.tar.gz"

wget -q -O /tmp/go.tar.gz ${download}

tar -C /tmp -xf /tmp/go.tar.gz
sudo mv /tmp/go /usr/local
sudo chown -R root:root /usr/local/go

# Ensure that the GOPATH tree is owned by vagrant:vagrant
mkdir -p #{GOPATH}
sudo chown -R vagrant:vagrant #{GOPATH}
sudo chown -R -f vagrant:vagrant $SRCROOT

# Ensure Go is on PATH
if [ ! -e /usr/bin/go ] ; then
ln -s /usr/local/go/bin/go /usr/bin/go
fi
if [ ! -e /usr/bin/gofmt ] ; then
ln -s /usr/local/go/bin/gofmt /usr/bin/gofmt
fi


# Ensure new sessions know about GOPATH
if [ ! -f /etc/profile.d/gopath.sh ] ; then
cat <<EOT > /etc/profile.d/gopath.sh
export GOPATH="#{GOPATH}"
export PATH="#{GOROOT}/bin:\\$GOPATH/bin:\\$PATH"
export SL_USERNAME=#{ENV['SL_USERNAME']}
export SL_API_KEY=#{ENV['SL_API_KEY']}
EOF
sudo mv /tmp/gopath.sh /etc/profile.d/gopath.sh
sudo chmod 0755 /etc/profile.d/gopath.sh
export PATH="#{GOPATH}/bin:\$PATH"
EOT
chmod 755 /etc/profile.d/gopath.sh
fi

source /etc/profile.d/gopath.sh


# Install some other stuff we need
sudo apt-get install -y curl git-core zip
sudo apt-get update && sudo apt-get install -y curl git-core zip build-essential

# Download and build Packer
source /etc/profile.d/gopath.sh
go get -u github.com/mitchellh/gox
gox -build-toolchain
go get -d -u github.com/mitchellh/packer
cd $GOPATH/src/github.com/mitchellh/packer
make updatedeps
# These next two lines cause duplicate files in $GOPATH/bin
go get -d -u github.com/hashicorp/packer
cd $GOPATH/src/github.com/hashicorp/packer
make
make dev

# Build packer-builder-softlayer
cd $GOPATH/#{PACKAGE_PATH}
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
go build
go test ./...
go install

# Make sure the gopath is usable by vagrant
sudo chown -R -f vagrant:vagrant $SRCROOT
sudo chown -R -f vagrant:vagrant #{GOPATH}
# Ensure vagrant still owns the GOPATH
sudo chown -R vagrant:vagrant #{GOPATH}

echo "Ready for development. Begin with cd $GOPATH/#{PACKAGE_PATH}"

SCRIPT

Vagrant.configure(2) do |config|
config.vm.box = "chef/ubuntu-12.04"
config.vm.box = "ubuntu/trusty64"

config.vm.synced_folder '.', "#{GOPATH}/#{PACKAGE_PATH}", id: 'src'
config.vm.synced_folder '.', "#{GOPATH}/#{PACKAGE_PATH}", id: 'src'

config.vm.provision 'shell', inline: script

Expand Down
Loading