Skip to content

Commit

Permalink
INT-378_single_node_optional_license (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
fernau authored Oct 17, 2017
1 parent dd25b3a commit 569486a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GRAPH
java (~> 1.50)
limits (~> 1.0.0)
poise-python (~> 1.6.0)
s3_file (~> 2.8.5)
tar (~> 2.1)
ohai (5.2.0)
poise (2.8.1)
Expand All @@ -26,6 +27,7 @@ GRAPH
poise-python (1.6.0)
poise (~> 2.7)
poise-languages (~> 2.0)
s3_file (2.8.5)
tar (2.1.1)
windows (3.1.3)
ohai (>= 4.0.0)
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
default['nexus_repository_manager']['nexus_download_sha256'] = '40b95b097b43cc8941a9700d24baf25ef94867286e43eaffa37cf188726bb2a7'
default['nexus_repository_manager']['sonatype']['path'] = '/opt/sonatype'
default['nexus_repository_manager']['nexus_data']['path'] = '/nexus-data'
default['nexus_repository_manager']['license_s3_bucket'] = nil
default['nexus_repository_manager']['license_s3_path'] = nil

# nexus.properties configuration
default['nexus_repository_manager']['properties']['application_port'] = '8081'
Expand Down
1 change: 1 addition & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
depends 'tar', '~> 2.1'
depends 'limits', '~> 1.0.0'
depends 'poise-python', '~> 1.6.0'
depends 's3_file', '~> 2.8.5'
17 changes: 9 additions & 8 deletions recipes/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@
end

python 'check instance health' do
code <<-EOH
import boto3, sys
instance_id = open('/var/lib/cloud/data/instance-id', 'r').readline().strip()
elb_client = boto3.client('elb', region_name='#{region}')
elbs = elb_client.describe_load_balancers()['LoadBalancerDescriptions']
elb_name = [e['LoadBalancerName'] for e in elbs if instance_id in [ i['InstanceId'] for i in e['Instances'] ]]
inst_health = elb_client.describe_instance_health(LoadBalancerName=elb_name[0], Instances=[{'InstanceId':instance_id}])
if inst_health['InstanceStates'][0]['State'] != 'InService': sys.exit(1)
code <<-EOH.gsub(/^\s+/, '')
import boto3, sys
instance_id = open('/var/lib/cloud/data/instance-id', 'r').readline().strip()
elb_client = boto3.client('elb', region_name='#{region}')
elbs = elb_client.describe_load_balancers()['LoadBalancerDescriptions']
elb_name = [e['LoadBalancerName'] for e in elbs if instance_id in [ i['InstanceId'] for i in e['Instances'] ]]
inst_health = elb_client.describe_instance_health(LoadBalancerName=elb_name[0], Instances=[{'InstanceId':instance_id}])
if inst_health['InstanceStates'][0]['State'] != 'InService': sys.exit(1)
EOH
retries 300
retry_delay 2
only_if { node['nexus_repository_manager']['properties']['clustered'] == 'true' }
end
10 changes: 10 additions & 0 deletions recipes/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,13 @@
owner 'root'
group 'root'
end

s3_file node['nexus_repository_manager']['nexus_data']['etc']['path'] + '/license.lic' do
remote_path node['nexus_repository_manager']['license_s3_path']
bucket node['nexus_repository_manager']['license_s3_bucket']
owner 'nexus'
group 'nexus'
mode '600'
action :create
not_if { node['nexus_repository_manager']['license_s3_bucket'].to_s.empty? }
end
2 changes: 2 additions & 0 deletions templates/nexus.properties.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ nexus.loadAsOSS=<%= node['nexus_repository_manager']['properties']['load_as_oss'
nexus.clustered=<%= node['nexus_repository_manager']['properties']['clustered'] %>
<% if node['nexus_repository_manager']['properties']['license_file'] %>
nexus.licenseFile=<%= node['nexus_repository_manager']['properties']['license_file'] %>
<% elsif node['nexus_repository_manager']['license_s3_bucket'] %>
nexus.licenseFile=<%= node['nexus_repository_manager']['nexus_data']['etc']['path'] + '/license.lic' %>
<% end %>

0 comments on commit 569486a

Please sign in to comment.