Compare commits

..

9 Commits

Author SHA1 Message Date
Matthew Hooker e3d65a193e Cut version 1.0.0 2017-04-04 13:05:41 -07:00
Matthew Hooker 8ea8ff683d prepare for version 1.0.0 2017-04-04 12:42:25 -07:00
Matthew Hooker 41203ddc3d Merge pull request #4759 from mitchellh/comcore
call out community vs core plugins
2017-04-04 12:38:09 -07:00
Matthew Hooker 416330bd9e Merge pull request #4758 from mitchellh/fix4680
provisioner/ansible-local: document staging dir
2017-04-04 12:02:44 -07:00
Matthew Hooker 9209a60b30 Merge pull request #4757 from mitchellh/fix4756
link to other downloads, not necessarily older.
2017-04-04 11:23:55 -07:00
Matthew Hooker 21321d2695 update changelog 2017-04-04 10:36:55 -07:00
Matthew Hooker 2be5ce2f16 Merge pull request #4752 from mitchellh/fix-4007
add sleep and retry to azure setup script
2017-04-04 10:35:27 -07:00
Matthew Hooker fec5cb3b86 update changelog 2017-04-03 11:26:54 -07:00
Matthew Hooker a242014aa9 Merge pull request #4749 from rickard-von-essen/issue-4608
builder/googlecompute: Revert to using default service account
2017-04-03 11:24:50 -07:00
10 changed files with 293 additions and 227 deletions
+9
View File
@@ -1,3 +1,12 @@
## 1.0.0 (April 4, 2017)
### BUG FIXES:
* builder/googlecompute: Use "default" service account. [GH-4749]
### IMPROVEMENTS:
* More diligently try to complete azure-setup.sh. [GH-4752]
## 1.0.0-rc3 (March 30, 2017)
### BUG FIXES:
+18 -19
View File
@@ -58,25 +58,24 @@ type Driver interface {
}
type InstanceConfig struct {
Address string
Description string
DiskSizeGb int64
DiskType string
Image *Image
MachineType string
Metadata map[string]string
Name string
Network string
NetworkProjectId string
OmitExternalIP bool
OnHostMaintenance string
Preemptible bool
Region string
Scopes []string
ServiceAccountEmail string
Subnetwork string
Tags []string
Zone string
Address string
Description string
DiskSizeGb int64
DiskType string
Image *Image
MachineType string
Metadata map[string]string
Name string
Network string
NetworkProjectId string
OmitExternalIP bool
OnHostMaintenance string
Preemptible bool
Region string
Scopes []string
Subnetwork string
Tags []string
Zone string
}
// WindowsPasswordConfig is the data structue that GCE needs to encrypt the created
+1 -1
View File
@@ -391,7 +391,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
},
ServiceAccounts: []*compute.ServiceAccount{
{
Email: c.ServiceAccountEmail,
Email: "default",
Scopes: c.Scopes,
},
},
+18 -19
View File
@@ -99,25 +99,24 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
var metadata map[string]string
metadata, err = c.createInstanceMetadata(sourceImage, sshPublicKey)
errCh, err = d.RunInstance(&InstanceConfig{
Address: c.Address,
Description: "New instance created by Packer",
DiskSizeGb: c.DiskSizeGb,
DiskType: c.DiskType,
Image: sourceImage,
MachineType: c.MachineType,
Metadata: metadata,
Name: name,
Network: c.Network,
NetworkProjectId: c.NetworkProjectId,
OmitExternalIP: c.OmitExternalIP,
OnHostMaintenance: c.OnHostMaintenance,
Preemptible: c.Preemptible,
Region: c.Region,
ServiceAccountEmail: c.Account.ClientEmail,
Scopes: c.Scopes,
Subnetwork: c.Subnetwork,
Tags: c.Tags,
Zone: c.Zone,
Address: c.Address,
Description: "New instance created by Packer",
DiskSizeGb: c.DiskSizeGb,
DiskType: c.DiskType,
Image: sourceImage,
MachineType: c.MachineType,
Metadata: metadata,
Name: name,
Network: c.Network,
NetworkProjectId: c.NetworkProjectId,
OmitExternalIP: c.OmitExternalIP,
OnHostMaintenance: c.OnHostMaintenance,
Preemptible: c.Preemptible,
Region: c.Region,
Scopes: c.Scopes,
Subnetwork: c.Subnetwork,
Tags: c.Tags,
Zone: c.Zone,
})
if err == nil {
+201 -179
View File
@@ -12,234 +12,256 @@ azure_tenant_id= # Derived from the account after login
location=
azure_object_id=
azureversion=
create_sleep=10
showhelp() {
echo "azure-setup"
echo ""
echo " azure-setup helps you generate packer credentials for Azure"
echo ""
echo " The script creates a resource group, storage account, application"
echo " (client), service principal, and permissions and displays a snippet"
echo " for use in your packer templates."
echo ""
echo " For simplicity we make a lot of assumptions and choose reasonable"
echo " defaults. If you want more control over what happens, please use"
echo " the azure-cli directly."
echo ""
echo " Note that you must already have an Azure account, username,"
echo " password, and subscription. You can create those here:"
echo ""
echo " - https://account.windowsazure.com/"
echo ""
echo "REQUIREMENTS"
echo ""
echo " - azure-cli"
echo " - jq"
echo ""
echo " Use the requirements command (below) for more info."
echo ""
echo "USAGE"
echo ""
echo " ./azure-setup.sh requirements"
echo " ./azure-setup.sh setup"
echo ""
echo "azure-setup"
echo ""
echo " azure-setup helps you generate packer credentials for Azure"
echo ""
echo " The script creates a resource group, storage account, application"
echo " (client), service principal, and permissions and displays a snippet"
echo " for use in your packer templates."
echo ""
echo " For simplicity we make a lot of assumptions and choose reasonable"
echo " defaults. If you want more control over what happens, please use"
echo " the azure-cli directly."
echo ""
echo " Note that you must already have an Azure account, username,"
echo " password, and subscription. You can create those here:"
echo ""
echo " - https://account.windowsazure.com/"
echo ""
echo "REQUIREMENTS"
echo ""
echo " - azure-cli"
echo " - jq"
echo ""
echo " Use the requirements command (below) for more info."
echo ""
echo "USAGE"
echo ""
echo " ./azure-setup.sh requirements"
echo " ./azure-setup.sh setup"
echo ""
}
requirements() {
found=0
found=0
azureversion=$(azure -v)
if [ $? -eq 0 ]; then
found=$((found + 1))
echo "Found azure-cli version: $azureversion"
else
echo "azure-cli is missing. Please install azure-cli from"
echo "https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/"
fi
azureversion=$(azure -v)
if [ $? -eq 0 ]; then
found=$((found + 1))
echo "Found azure-cli version: $azureversion"
else
echo "azure-cli is missing. Please install azure-cli from"
echo "https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/"
fi
jqversion=$(jq --version)
if [ $? -eq 0 ]; then
found=$((found + 1))
echo "Found jq version: $jqversion"
else
echo "jq is missing. Please install jq from"
echo "https://stedolan.github.io/jq/"
fi
jqversion=$(jq --version)
if [ $? -eq 0 ]; then
found=$((found + 1))
echo "Found jq version: $jqversion"
else
echo "jq is missing. Please install jq from"
echo "https://stedolan.github.io/jq/"
fi
if [ $found -lt 2 ]; then
exit 1
fi
if [ $found -lt 2 ]; then
exit 1
fi
}
askSubscription() {
azure account list
echo ""
echo "Please enter the Id of the account you wish to use. If you do not see"
echo "a valid account in the list press Ctrl+C to abort and create one."
echo "If you leave this blank we will use the Current account."
echo -n "> "
read azure_subscription_id
if [ "$azure_subscription_id" != "" ]; then
azure account set $azure_subscription_id
else
azure_subscription_id=$(azure account show --json | jq -r .[].id)
fi
azure_tenant_id=$(azure account show --json | jq -r .[].tenantId)
echo "Using subscription_id: $azure_subscription_id"
echo "Using tenant_id: $azure_tenant_id"
azure account list
echo ""
echo "Please enter the Id of the account you wish to use. If you do not see"
echo "a valid account in the list press Ctrl+C to abort and create one."
echo "If you leave this blank we will use the Current account."
echo -n "> "
read azure_subscription_id
if [ "$azure_subscription_id" != "" ]; then
azure account set $azure_subscription_id
else
azure_subscription_id=$(azure account show --json | jq -r .[].id)
fi
azure_tenant_id=$(azure account show --json | jq -r .[].tenantId)
echo "Using subscription_id: $azure_subscription_id"
echo "Using tenant_id: $azure_tenant_id"
}
askName() {
echo ""
echo "Choose a name for your resource group, storage account and client"
echo "client. This is arbitrary, but it must not already be in use by"
echo "any of those resources. ALPHANUMERIC ONLY. Ex: mypackerbuild"
echo -n "> "
read meta_name
echo ""
echo "Choose a name for your resource group, storage account and client"
echo "client. This is arbitrary, but it must not already be in use by"
echo "any of those resources. ALPHANUMERIC ONLY. Ex: mypackerbuild"
echo -n "> "
read meta_name
}
askSecret() {
echo ""
echo "Enter a secret for your application. We recommend generating one with"
echo "openssl rand -base64 24. If you leave this blank we will attempt to"
echo "generate one for you using openssl. THIS WILL BE SHOWN IN PLAINTEXT."
echo "Ex: mypackersecret8734"
echo -n "> "
read azure_client_secret
if [ "$azure_client_secret" = "" ]; then
azure_client_secret=$(openssl rand -base64 24)
if [ $? -ne 0 ]; then
echo "Error generating secret"
exit 1
fi
echo "Generated client_secret: $azure_client_secret"
fi
echo ""
echo "Enter a secret for your application. We recommend generating one with"
echo "openssl rand -base64 24. If you leave this blank we will attempt to"
echo "generate one for you using openssl. THIS WILL BE SHOWN IN PLAINTEXT."
echo "Ex: mypackersecret8734"
echo -n "> "
read azure_client_secret
if [ "$azure_client_secret" = "" ]; then
azure_client_secret=$(openssl rand -base64 24)
if [ $? -ne 0 ]; then
echo "Error generating secret"
exit 1
fi
echo "Generated client_secret: $azure_client_secret"
fi
}
askLocation() {
azure location list
echo ""
echo "Choose which region your resource group and storage account will be created."
echo -n "> "
read location
azure location list
echo ""
echo "Choose which region your resource group and storage account will be created."
echo -n "> "
read location
}
createResourceGroup() {
echo "==> Creating resource group"
azure group create -n $meta_name -l $location
if [ $? -eq 0 ]; then
azure_group_name=$meta_name
else
echo "Error creating resource group: $meta_name"
exit 1
fi
echo "==> Creating resource group"
azure group create -n $meta_name -l $location
if [ $? -eq 0 ]; then
azure_group_name=$meta_name
else
echo "Error creating resource group: $meta_name"
return 1
fi
}
createStorageAccount() {
echo "==> Creating storage account"
azure storage account create -g $meta_name -l $location --sku-name LRS --kind Storage $meta_name
if [ $? -eq 0 ]; then
azure_storage_name=$meta_name
else
echo "Error creating storage account: $meta_name"
exit 1
fi
echo "==> Creating storage account"
azure storage account create -g $meta_name -l $location --sku-name LRS --kind Storage $meta_name
if [ $? -eq 0 ]; then
azure_storage_name=$meta_name
else
echo "Error creating storage account: $meta_name"
return 1
fi
}
createApplication() {
echo "==> Creating application"
azure_client_id=$(azure ad app create -n $meta_name -i http://$meta_name --home-page http://$meta_name -p $azure_client_secret --json | jq -r .appId)
if [ $? -ne 0 ]; then
echo "Error creating application: $meta_name @ http://$meta_name"
exit 1
fi
echo "==> Creating application"
azure_client_id=$(azure ad app create -n $meta_name -i http://$meta_name --home-page http://$meta_name -p $azure_client_secret --json | jq -r .appId)
if [ $? -ne 0 ]; then
echo "Error creating application: $meta_name @ http://$meta_name"
return 1
fi
}
createServicePrincipal() {
echo "==> Creating service principal"
# Azure CLI 0.10.2 introduced a breaking change, where appId must be supplied with the -a switch
# prior version accepted appId as the only parameter without a switch
newer_syntax=false
IFS='.' read -ra azureversionsemver <<< "$azureversion"
if [ ${azureversionsemver[0]} -ge 0 ] && [ ${azureversionsemver[1]} -ge 10 ] && [ ${azureversionsemver[2]} -ge 2 ]; then
newer_syntax=true
fi
echo "==> Creating service principal"
# Azure CLI 0.10.2 introduced a breaking change, where appId must be supplied with the -a switch
# prior version accepted appId as the only parameter without a switch
newer_syntax=false
IFS='.' read -ra azureversionsemver <<< "$azureversion"
if [ ${azureversionsemver[0]} -ge 0 ] && [ ${azureversionsemver[1]} -ge 10 ] && [ ${azureversionsemver[2]} -ge 2 ]; then
newer_syntax=true
fi
if [ "${newer_syntax}" = true ]; then
azure_object_id=$(azure ad sp create -a $azure_client_id --json | jq -r .objectId)
else
azure_object_id=$(azure ad sp create $azure_client_id --json | jq -r .objectId)
fi
if [ "${newer_syntax}" = true ]; then
azure_object_id=$(azure ad sp create -a $azure_client_id --json | jq -r .objectId)
else
azure_object_id=$(azure ad sp create $azure_client_id --json | jq -r .objectId)
fi
if [ $? -ne 0 ]; then
echo "Error creating service principal: $azure_client_id"
exit 1
fi
if [ $? -ne 0 ]; then
echo "Error creating service principal: $azure_client_id"
return 1
fi
}
createPermissions() {
echo "==> Creating permissions"
azure role assignment create --objectId $azure_object_id -o "Owner" -c /subscriptions/$azure_subscription_id
# We want to use this more conservative scope but it does not work with the
# current implementation which uses temporary resource groups
# azure role assignment create --spn http://$meta_name -g $azure_group_name -o "API Management Service Contributor"
if [ $? -ne 0 ]; then
echo "Error creating permissions for: http://$meta_name"
exit 1
fi
echo "==> Creating permissions"
azure role assignment create --objectId $azure_object_id -o "Owner" -c /subscriptions/$azure_subscription_id
# We want to use this more conservative scope but it does not work with the
# current implementation which uses temporary resource groups
# azure role assignment create --spn http://$meta_name -g $azure_group_name -o "API Management Service Contributor"
if [ $? -ne 0 ]; then
echo "Error creating permissions for: http://$meta_name"
return 1
fi
}
showConfigs() {
echo ""
echo "Use the following configuration for your packer template:"
echo ""
echo "{"
echo " \"client_id\": \"$azure_client_id\","
echo " \"client_secret\": \"$azure_client_secret\","
echo " \"object_id\": \"$azure_object_id\","
echo " \"subscription_id\": \"$azure_subscription_id\","
echo " \"tenant_id\": \"$azure_tenant_id\","
echo " \"resource_group_name\": \"$azure_group_name\","
echo " \"storage_account\": \"$azure_storage_name\","
echo "}"
echo ""
echo ""
echo "Use the following configuration for your packer template:"
echo ""
echo "{"
echo " \"client_id\": \"$azure_client_id\","
echo " \"client_secret\": \"$azure_client_secret\","
echo " \"object_id\": \"$azure_object_id\","
echo " \"subscription_id\": \"$azure_subscription_id\","
echo " \"tenant_id\": \"$azure_tenant_id\","
echo " \"resource_group_name\": \"$azure_group_name\","
echo " \"storage_account\": \"$azure_storage_name\","
echo "}"
echo ""
}
doSleep() {
local sleep_time=${PACKER_SLEEP_TIME-$create_sleep}
echo ""
echo "Sleeping for ${sleep_time} seconds to wait for resources to be "
echo "created. If you get an error about a resource not existing, you can "
echo "try increasing the amount of time we wait after creating resources "
echo "by setting PACKER_SLEEP_TIME to something higher than the default."
echo ""
sleep $sleep_time
}
retryable() {
n=0
until [ $n -ge $1 ]
do
$2 && return 0
echo "$2 failed. Retrying..."
n=$[$n+1]
doSleep
done
echo "$2 failed after $1 tries. Exiting."
exit 1
}
setup() {
requirements
requirements
azure config mode arm
azure login
azure config mode arm
azure login
askSubscription
askName
askSecret
askLocation
askSubscription
askName
askSecret
askLocation
# Some of the resources take a while to converge in the API. To make the
# script more reliable we'll add a sleep after we create each resource.
# Some of the resources take a while to converge in the API. To make the
# script more reliable we'll add a sleep after we create each resource.
createResourceGroup
sleep 5
createStorageAccount
sleep 5
createApplication
sleep 5
createServicePrincipal
sleep 5
createPermissions
retryable 3 createResourceGroup
retryable 3 createStorageAccount
retryable 3 createApplication
retryable 3 createServicePrincipal
retryable 3 createPermissions
showConfigs
showConfigs
}
case "$1" in
requirements)
requirements
;;
setup)
setup
;;
*)
showhelp
;;
requirements)
requirements
;;
setup)
setup
;;
*)
showhelp
;;
esac
+1 -1
View File
@@ -14,7 +14,7 @@ const Version = "1.0.0"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc.
const VersionPrerelease = "rc3"
const VersionPrerelease = ""
func FormattedVersion() string {
var versionString bytes.Buffer
+1 -1
View File
@@ -2,7 +2,7 @@ set :base_url, "https://www.packer.io/"
activate :hashicorp do |h|
h.name = "packer"
h.version = "0.12.3"
h.version = "1.0.0"
h.github_slug = "mitchellh/packer"
h.website_root = "website"
end
@@ -127,9 +127,12 @@ chi-appservers
`staging_directory`/roles. By default, this is empty.
- `staging_directory` (string) - The directory where all the configuration of
Ansible by Packer will be placed. By default this
is "/tmp/packer-provisioner-ansible-local". This directory doesn't need to
exist but must have proper permissions so that the SSH user that Packer uses
is able to create directories and write into this folder. If the permissions
are not correct, use a shell provisioner prior to this to configure
it properly.
Ansible by Packer will be placed. By default this is
`/tmp/packer-provisioner-ansible-local/<uuid>`, where `<uuid>` is replaced
with a unique ID so that this provisioner can be run more than once. If
you'd like to know the location of the staging directory in advance, you
should set this to a known location. This directory doesn't need to exist
but must have proper permissions so that the SSH user that Packer uses is
able to create directories and write into this folder. If the permissions
are not correct, use a shell provisioner prior to this to configure it
properly.
@@ -44,3 +44,37 @@ power of Packer templates.
## Other
- [suitcase](https://github.com/tmclaugh/suitcase) - Packer based build system for CentOS OS images
## Community Maintained Plugins
The following plugins are maintained by HashiCorp. Any plugins not on this list
are maintained by the community, and not actively contributed to by HashiCorp,
although they are still distributed with Packer.
### Builders
- Amazon EC2
- Azure
- Docker
- Google Cloud
- VMWare
- VirtualBox
### Provisioners
- File
- PowerShell
- Shell
- Windows Restart
- Windows Shell
### Post-Processors
- Amazon Import
- Artifice
- Atlas
- Docker
- Local Shell
- Manifest
- Vagrant
- Vagrant Cloud
+1 -1
View File
@@ -26,7 +26,7 @@ description: |-
verify the checksums signature file
</a>
which has been signed using <a href="https://hashicorp.com/security.html" target="_blank" rel="nofollow noopener noreferrer">HashiCorp's GPG key</a>.
You can also <a href="https://releases.hashicorp.com/packer/" target="_blank" rel="nofollow noopener noreferrer">download older versions of Packer</a> from the releases service.
You can also <a href="https://releases.hashicorp.com/packer/" target="_blank" rel="nofollow noopener noreferrer">download other versions of Packer</a> from the releases service.
</p>
<p>
Check out the <a href="https://github.com/mitchellh/packer/blob/v<%= latest_version %>/CHANGELOG.md">v<%= latest_version %> CHANGELOG</a> for information on the latest release.