Skip to content

Commit

Permalink
test chef attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
hgreebe committed Apr 10, 2024
1 parent cd9c2f1 commit ca665c0
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
# limitations under the License.

resource_name :remote_object
provides :remote_object
unified_mode true

# Resource to retrieve a remote object either using the S3 or HTTPS protocol
property :url, required: true,
description: 'Source URI of the remote file'
property :destination, required: true,
description: 'Local destination path where to store the file'
property :sensitive, [true, false],
default: false,
description: 'mark the resource as senstive'

default_action :get

action :get do
if !new_resource.url.blank? && !new_resource.destination.blank?
source_url = new_resource.url
local_path = new_resource.destination
# if running a test skip credential check
no_sign_request = kitchen_test? ? "--no-sign-request" : ""

if source_url.start_with?("s3")
Chef::Log.debug("Retrieving remote Object from #{source_url} to #{local_path} using S3 protocol")
# download file using s3 protocol
fetch_command = "#{cookbook_virtualenv_path}/bin/aws s3 cp" \
" --region #{node['cluster']['region']}" \
" #{no_sign_request}" \
" #{source_url}" \
" #{local_path}"

Chef::Log.warn("executing command #{fetch_command} ")
execute "retrieve_object_with_s3_protocol" do
command fetch_command
retries 3
retry_delay 5
end
else
Chef::Log.debug("Retrieving remote Object from #{source_url} to #{local_path}")

# download file using standard chef behavior
remote_file "retrieve_object" do
path local_path
source source_url
sensitive new_resource.sensitive
retries 3
retry_delay 5
end
end
else
Chef::Log.warn("Either source or destination is not defined: #{new_resource.url} to #{new_resource.destination}")
end
end
7 changes: 6 additions & 1 deletion cookbooks/aws-parallelcluster-slurm/attributes/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
default['cluster']['slurm']['commit'] = ''
default['cluster']['slurm']['branch'] = ''
default['cluster']['slurm']['sha256'] = '832bc076d8ac9fd44cf2bf539c5046d7aa3ec20fb6c699693552dce3e5ad5588'
default['cluster']['slurm']['base_url'] = "s3://test-aws-parallelcluster/archives/slurm"
default['cluster']['slurm']['base_url'] = "https://github.com/SchedMD/slurm/archive"

if !node['cluster']['dependencies_from_s3'].nil? && !node['cluster']['dependencies_from_s3'].empty?
default['cluster']['slurm']['base_url'] = "https://test-aws-parallelcluster.s3.amazonaws.com/archives/slurm"
end

# Munge
default['cluster']['munge']['munge_version'] = '0.5.15'
default['cluster']['munge']['sha256'] = '51b2c81d1a7ec2ab5d486fa51b50c7e79eb1810ca6687b6ed65f3601abc55614'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
include_recipe 'aws-parallelcluster-slurm::slurm_users'

# Get slurm tarball from s3
remote_object 'Get slurm tarball from s3' do
url slurm_url
destination slurm_tarball
sensitive true
if !node['cluster']['dependencies_from_s3'].nil? && !node['cluster']['dependencies_from_s3'].empty?
remote_object 'Get slurm tarball from s3' do
url slurm_url
destination slurm_tarball
sensitive true
end
else
# Get slurm tarball
remote_file slurm_tarball do
source slurm_url
mode '0644'
retries 3
retry_delay 5
checksum slurm_sha256
action :create_if_missing
end
end

# Get slurm tarball
#remote_file slurm_tarball do
# source slurm_url
# mode '0644'
# retries 3
# retry_delay 5
# checksum slurm_sha256
# action :create_if_missing
#end

# Copy Slurm patches
remote_directory "#{node['cluster']['sources_dir']}/slurm_patches" do
source 'install_slurm/slurm_patches'
Expand Down

0 comments on commit ca665c0

Please sign in to comment.