in cookbooks/aws-parallelcluster-test/libraries/helpers.rb [111:131]
def check_imds_access(user, is_allowed)
bash "check IMDS access for user #{user}" do
cwd Chef::Config[:file_cache_path]
code <<-TEST
sudo -u
[[ $? = 0 ]] && actual_is_allowed="true" || actual_is_allowed="false"
if [[ "$actual_is_allowed" != "#{is_allowed}" ]]; then
>&2 echo "User #{is_allowed ? 'should' : 'should not'} have access to IMDS (IPv4): #{user}"
exit 1
fi
sudo -u
[[ $? = 0 ]] && actual_is_allowed="true" || actual_is_allowed="false"
if [[ "$actual_is_allowed" != "#{is_allowed}" ]]; then
>&2 echo "User #{is_allowed ? 'should' : 'should not'} have access to IMDS (IPv6): #{user}"
exit 1
fi
TEST
end
end