-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added OCFP, bumped stemcell, added cloud-config
- Loading branch information
FiveTwenty Team
committed
Dec 3, 2024
1 parent
45f5f33
commit dd3f48f
Showing
7 changed files
with
241 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package Genesis::Hook::Blueprint::Vault v4.0.0; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
# Only needed for development | ||
BEGIN {push @INC, $ENV{GENESIS_LIB} ? $ENV{GENESIS_LIB} : $ENV{HOME}.'/.genesis/lib'} | ||
|
||
use parent qw(Genesis::Hook::Blueprint); | ||
|
||
sub init { | ||
my $class = shift; | ||
my $obj = $class->SUPER::init(@_); | ||
$obj->check_minimum_genesis_version('3.1.0-rc.9'); | ||
return $obj; | ||
} | ||
|
||
sub perform { | ||
my ($self) = @_; | ||
return 1 if $self->completed; | ||
|
||
$self->add_files( | ||
'manifests/vault.yml', | ||
'manifests/releases/safe.yml' | ||
); | ||
|
||
my $iaas = $self->iaas; | ||
my $ips = $self->env->lookup('params.ips', []); | ||
|
||
my $dynamic_static_fragment = ''; | ||
if ($want_feature 'ocfp') { | ||
# Determine instance count and IPs from ocfp config | ||
my $subnets = $self->env->ocfp_config_lookup('vpc.subnets'); | ||
my $prefix = $self->env->ocfp_subnet_prefix; | ||
my $az_map = $self->director_exodus_lookup('/network')->{azs}; | ||
my (@ips, @azs) = (); | ||
for my $subnet (sort grep {/^$prefix/} keys %$sn) { | ||
my $ip = $sn->{$_}{'reserved-ips'}{'vault_ip'}; | ||
next unless $ip; | ||
push @ips, $ip; | ||
push @azs, $az_map->{$sn->{$_}{az}}->{name}; | ||
} | ||
|
||
my $instances = $self->env->lookup('params.ocfp_instances'); | ||
bail( | ||
"Only %s instances available under OCFP; environment requested %s", | ||
@ips, $instances | ||
) if ($instances > @ips); | ||
$instances ||= @ips; | ||
|
||
@ips = @ips[0..$instances-1]; | ||
@azs = @azs[0..$instances-1]; | ||
my $network_name = "$GENESIS_ENV.$GENESIS_TYPE.net-vault"; | ||
|
||
my $dynamic_static_fragment = << "EOF"; | ||
exodus: | ||
ips: $(\(join ',',@ips)) | ||
instance_groups: | ||
- name: vault | ||
azs:${\(join "\n - ", '','(( replace ))', @azs)} | ||
instances: $instances | ||
networks: | ||
- (( replace )) | ||
- name: $network_name | ||
static_ips:${\(join "\n - ", '', @ips)} | ||
EOF | ||
|
||
} elsif (my $instances = @$ips) { | ||
my $dynamic-static-ips = <<"EOF"; | ||
exodus: | ||
ips: $ips | ||
instance_groups: | ||
- name: vault | ||
instances: $instance | ||
networks: | ||
- name: vault | ||
static_ips:${\(join '\n - ', '', $ips)} | ||
EOF | ||
} | ||
|
||
if ($dynamic_static_fragment) { | ||
my $satics_file = "manifests/network.dynamic.yml"; | ||
mkfile_or_fail($self->env->kit->workpath($statics_file), 0644, $contents); | ||
$self->add_files($statics_file); | ||
} | ||
|
||
$self->add_files('manifests/azure.yml') if ($self->iaas eq 'azure'); | ||
|
||
my @invalid_features = (); | ||
for my $feature ($self->features) { | ||
if ($feature eq 'ocfp') { | ||
# TODO: Check if iaas-specific ocfp file is present, and error if not. | ||
$self->add_files( | ||
'manifests/ocfp.yml', | ||
); | ||
} elsif (-f "$ENV{GENESIS_ROOT}/${feature}.yml") { | ||
$self->add_files("$ENV{GENESIS_ROOT}/${feature}.yml") | ||
} else { | ||
push @invalid_features, $feature; | ||
} | ||
} | ||
|
||
bail( | ||
"Invalid %s encountered: %s", | ||
count_nouns(scalar(@invalid_features), 'feature', suppress_count => 1), | ||
join(', ', @invalid_features) | ||
) if @invalid_features; | ||
|
||
$self->done(1); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package Genesis::Hook::CloudConfig::Bosh v3.2.0; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
# Only needed for development | ||
BEGIN {push @INC, $ENV{GENESIS_LIB} ? $ENV{GENESIS_LIB} : $ENV{HOME}.'/.genesis/lib'} | ||
|
||
use parent qw(Genesis::Hook::CloudConfig); | ||
|
||
use Genesis::Hook::CloudConfig::Helpers qw/gigabytes megabytes/; | ||
|
||
use Genesis qw//; | ||
use JSON::PP; | ||
|
||
sub init { | ||
my $class = shift; | ||
my $obj = $class->SUPER::init(@_); | ||
$obj->check_minimum_genesis_version('3.1.0-rc.4'); | ||
return $obj; | ||
} | ||
|
||
sub perform { | ||
my ($self) = @_; | ||
return 1 if $self->completed; | ||
|
||
my $config = $self->build_cloud_config({ | ||
'networks' => [ | ||
$self->network_definition('vault', strategy => 'ocfp', | ||
dynamic_subnets => { | ||
allocation => { | ||
size => 0, | ||
statics => 0, | ||
}, | ||
cloud_properties_for_iaas => { | ||
openstack => { | ||
'net_id' => $self->network_reference('id'), # TODO: $self->subnet_reference('net_id'), | ||
'security_groups' => ['default'] #$self->subnet_reference('sgs', 'get_security_groups'), | ||
}, | ||
}, | ||
}, | ||
) | ||
], | ||
'vm_types' => [ | ||
$self->vm_type_definition('vault', | ||
cloud_properties_for_iaas => { | ||
openstack => { | ||
'instance_type' => $self->for_scale({ | ||
dev => 'm1.2', | ||
prod => 'm1.3' | ||
}, 'm1.2'), | ||
'boot_from_volume' => $self->TRUE, | ||
'root_disk' => { | ||
'size' => 32 # in gigabytes | ||
}, | ||
}, | ||
}, | ||
), | ||
], | ||
'disk_types' => [ | ||
$self->disk_type_definition('vault', | ||
common => { | ||
disk_size => $self->for_scale({ # add $self->for_feature('internal-blobstore') | ||
dev => gigabytes(64), | ||
prod => gigabytes(128) | ||
}, gigabytes(96)), | ||
}, | ||
cloud_properties_for_iaas => { | ||
openstack => { | ||
'type' => 'storage_premium_perf6', | ||
}, | ||
}, | ||
), | ||
], | ||
}); | ||
|
||
$self->done($config); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
--- | ||
name: vault | ||
version: 1.6.0 | ||
version: 2.0.0 | ||
|
||
author: James Hunt <[email protected]> | ||
author: | ||
- James Hunt <[email protected]> | ||
- Dennis Bell <[email protected]> | ||
- Kevin Rutten <krutten@fivetwenty> | ||
code: https://github.com/genesis-community/vault-genesis-kit | ||
docs: https://genesisproject.io/docs/ | ||
|
||
genesis_version_min: 2.7.0 | ||
genesis_version_min: 3.1.0-rc.9 | ||
|
||
certificates: | ||
base: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
params: | ||
vault_network: (( concat meta.ocfp.env.cloud "net-bosh" )) | ||
vault_vm_type: (( concat meta.ocfp.env.cloud "vm-bosh" )) | ||
vault_disk_type: (( concat meta.ocfp.env.cloud "disk-bosh" )) | ||
|
||
meta: | ||
ocfp: | ||
env: | ||
cloud: (( concat genesis.env "." genesis.type "." )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters