Commit d0067fc6 authored by Rich's avatar Rich
Browse files

Resolve Azure authenticator only when actually required

parent efb53141
......@@ -3,7 +3,7 @@
_gemname=terraform-wrapper
pkgname=ruby-${_gemname}
pkgver=1.0.1
pkgver=1.0.2
pkgrel=1
pkgdesc="A ruby wrapper for managing Terraform binaries and remote state."
arch=(any)
......
......@@ -22,7 +22,7 @@ module TerraformWrapper
###############################################################################
def self.define_tasks(component:, options: Hash.new, service:)
def self.deployment_tasks(component:, options: Hash.new, service:)
@logger.info("Building tasks for service: #{service}, component: #{component}...")
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
......
......@@ -25,13 +25,13 @@ module TerraformWrapper
###############################################################################
@password = nil
@keyvault = nil
@secret_username = nil
@secret_password = nil
###############################################################################
attr_reader :subscription
attr_reader :tenant
attr_reader :username
@subscription
###############################################################################
......@@ -42,10 +42,17 @@ module TerraformWrapper
###############################################################################
def auth()
ENV["ARM_SUBSCRIPTION_ID"] = @subscription
ENV["ARM_TENANT_ID"] = @tenant
ENV["ARM_CLIENT_ID"] = @username unless @username.nil?
ENV["ARM_CLIENT_SECRET"] = @password unless @password.nil?
details = subscription_details(subscription: @subscription)
subscription = details["id"]
tenant = details["tenant"]
username = @keyvault.nil? ? nil : secret(vault: @keyvault, name: @secret_username)
password = @keyvault.nil? ? nil : secret(vault: @keyvault, name: @secret_password)
ENV["ARM_SUBSCRIPTION_ID"] = subscription
ENV["ARM_TENANT_ID"] = tenant
ENV["ARM_CLIENT_ID"] = username unless username.nil?
ENV["ARM_CLIENT_SECRET"] = password unless password.nil?
logger.success("Azure authenticator environment variables set!")
end
......@@ -151,20 +158,13 @@ module TerraformWrapper
end
begin
subscription = subscription % @variables.identifiers
keyvault = keyvault % @variables.identifiers unless keyvault.nil?
username = username % @variables.identifiers unless keyvault.nil?
password = password % @variables.identifiers unless keyvault.nil?
@subscription = subscription % @variables.identifiers
@keyvault = keyvault % @variables.identifiers unless keyvault.nil?
@secret_username = username % @variables.identifiers unless keyvault.nil?
@secret_password = password % @variables.identifiers unless keyvault.nil?
rescue
logger.fatal("Azure authenticator options contain identifiers that are not included in the configuration file!")
end
details = subscription_details(subscription: subscription)
@subscription = details["id"]
@tenant = details["tenant"]
@username = keyvault.nil? ? nil : secret(vault: keyvault, name: username)
@password = keyvault.nil? ? nil : secret(vault: keyvault, name: password)
end
###############################################################################
......
......@@ -4,7 +4,7 @@ module TerraformWrapper
###############################################################################
VERSION = "1.0.1"
VERSION = "1.0.2"
###############################################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment