mirror of
https://github.com/puppetlabs/vmpooler-provider-ec2.git
synced 2026-01-26 02:28:40 -05:00
Merge pull request #3 from puppetlabs/dio-3163
Change the way we load secrets so that we do not have to pass them as…
This commit is contained in:
commit
7f53932152
4 changed files with 42 additions and 14 deletions
|
|
@ -20,7 +20,7 @@ aws authorization is handled via two required ENV vars
|
|||
When you add the pool config `provision: true` to a pool, the new VMs will also get initialized with extra steps to setup the sshd config via NET:SSH
|
||||
These steps expect two environment vars
|
||||
1. ROOT_KEYS_SCRIPT: (optional) the URI location of a script (eg https in github) that will be run to setup keys. If not set, this will be skipped
|
||||
2. KEY_FILE_LOCATION: (required) the location on local disk where the ssh key resides for VMPooler to connect via SSH to the EC2 node
|
||||
2. AWS_KEY_FILE_LOCATION: (required) the location on local disk where the ssh key resides for VMPooler to connect via SSH to the EC2 node
|
||||
|
||||
### DNS
|
||||
AWS will setup a private ip and private dns hostname for the VM once running. Optionally we can setup a human readable DNS entry to resolve the VMPooler provider `spicy-proton` fqdn
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module Vmpooler
|
|||
ROOT_KEYS_SYNC_CMD = "curl -k -o - -L #{ROOT_KEYS_SCRIPT} | %s"
|
||||
|
||||
def self.setup_node_by_ssh(host, platform)
|
||||
@key_file = ENV['KEY_FILE_LOCATION'] || '/app/abs/.ssh/abs-aws-ec2.rsa'
|
||||
@key_file = ENV['AWS_KEY_FILE_LOCATION']
|
||||
conn = check_ssh_accepting_connections(host, platform)
|
||||
configure_host(host, platform, conn)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ module Vmpooler
|
|||
def initialize(config, logger, metrics, redis_connection_pool, name, options)
|
||||
super(config, logger, metrics, redis_connection_pool, name, options)
|
||||
|
||||
@aws_access_key = ENV['ABS_AWS_ACCESS_KEY']
|
||||
@aws_secret_key = ENV['ABS_AWS_SECRET_KEY']
|
||||
@aws_access_key = ENV['ABS_AWS_ACCESS_KEY'] || provider_config['ABS_AWS_ACCESS_KEY']
|
||||
@aws_secret_key = ENV['ABS_AWS_SECRET_KEY'] || provider_config['ABS_AWS_SECRET_KEY']
|
||||
|
||||
task_limit = global_config[:config].nil? || global_config[:config]['task_limit'].nil? ? 10 : global_config[:config]['task_limit'].to_i
|
||||
# The default connection pool size is:
|
||||
|
|
@ -123,10 +123,16 @@ module Vmpooler
|
|||
pool = pool_config(pool_name)
|
||||
raise("Pool #{pool_name} does not exist for the provider #{name}") if pool.nil?
|
||||
|
||||
filters = [{
|
||||
name: 'tag:pool',
|
||||
values: [pool_name]
|
||||
}]
|
||||
filters = [
|
||||
{
|
||||
name: 'tag:pool',
|
||||
values: [pool_name]
|
||||
},
|
||||
{
|
||||
name: 'instance-state-name',
|
||||
values: %w[pending running shutting-down stopping stopped]
|
||||
}
|
||||
]
|
||||
instance_list = connection.instances(filters: filters)
|
||||
|
||||
return vms if instance_list.first.nil?
|
||||
|
|
|
|||
|
|
@ -53,16 +53,38 @@ EOT
|
|||
|
||||
describe '#manual tests live' do
|
||||
context 'in itsysops' do
|
||||
let(:vmname) { "instance-50" }
|
||||
let(:poolname) { "ubuntu-2004-arm64" }
|
||||
let(:config) { YAML.load(<<~EOT
|
||||
---
|
||||
:config:
|
||||
max_tries: 3
|
||||
retry_factor: 10
|
||||
:providers:
|
||||
:ec2:
|
||||
connection_pool_timeout: 1
|
||||
zone: '#{zone}'
|
||||
region: '#{region}'
|
||||
:pools:
|
||||
- name: '#{poolname}'
|
||||
alias: [ 'mockpool' ]
|
||||
amisize: 'a1.large'
|
||||
template: 'ami-03c1b544a7566b3e5'
|
||||
size: 5
|
||||
timeout: 10
|
||||
ready_ttl: 1440
|
||||
provider: 'ec2'
|
||||
provision: 'true'
|
||||
EOT
|
||||
)
|
||||
}
|
||||
before(:each) {
|
||||
config['provision'] = "true"
|
||||
allow(subject).to receive(:dns).and_call_original
|
||||
}
|
||||
let(:vmname) { "instance-46" }
|
||||
let(:poolname) { "ubuntu-2004-arm64" }
|
||||
skip 'gets a vm' do
|
||||
|
||||
# result = subject.create_vm(poolname, vmname)
|
||||
subject.provision_node_aws("ip-10-227-4-27.amz-dev.puppet.net", poolname)
|
||||
result = subject.create_vm(poolname, vmname)
|
||||
#subject.vms_in_pool("amazon-6-x86_64-ec2")
|
||||
#subject.provision_node_aws("ip-10-227-4-97.amz-dev.puppet.net", poolname)
|
||||
# subject.create_snapshot(poolname, vmname, "foo")
|
||||
#subject.create_disk(poolname, vmname, 10)
|
||||
# a = subject.destroy_vm(poolname, vmname)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue