-
Notifications
You must be signed in to change notification settings - Fork 194
Add puppetcore macos support #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,36 @@ | |
$productversion_array = split($facts['os']['macosx']['version']['major'], '[.]') | ||
$productversion_major = $productversion_array[0] | ||
} | ||
|
||
if $puppet_agent::absolute_source { | ||
$source = $puppet_agent::absolute_source | ||
$source = if $puppet_agent::absolute_source { | ||
$puppet_agent::absolute_source | ||
} elsif ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) { | ||
$pe_server_version = pe_build_version() | ||
if $puppet_agent::alternate_pe_source { | ||
$source = "${puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg" | ||
"${puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${productversion_major}.dmg" | ||
} elsif $puppet_agent::source { | ||
$source = "${puppet_agent::source}/packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg" | ||
"${puppet_agent::source}/packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${productversion_major}.dmg" | ||
joshcooper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
"puppet:///pe_packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${productversion_major}.dmg" | ||
} | ||
} elsif $puppet_agent::collection =~ /core/ { | ||
if count(split($puppet_agent::prepare::package_version, '\.')) > 3 { | ||
"https://artifacts-puppetcore.puppet.com/v1/download?type=native&version=${puppet_agent::prepare::package_version}&os_name=osx&os_version=${productversion_major}&os_arch=${puppet_agent::arch}&dev=true" | ||
} else { | ||
$source = "puppet:///pe_packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want to keep |
||
"https://artifacts-puppetcore.puppet.com/v1/download?type=native&version=${puppet_agent::prepare::package_version}&os_name=osx&os_version=${productversion_major}&os_arch=${puppet_agent::arch}" | ||
} | ||
} else { | ||
$source = "${puppet_agent::mac_source}/mac/${puppet_agent::collection}/${productversion_major}/${puppet_agent::arch}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg" | ||
"${puppet_agent::mac_source}/mac/${puppet_agent::collection}/${productversion_major}/${puppet_agent::arch}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${productversion_major}.dmg" | ||
joshcooper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
$destination_name = if $puppet_agent::collection =~ /core/ { | ||
"${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${productversion_major}.dmg" | ||
} else { | ||
undef | ||
} | ||
|
||
class { 'puppet_agent::prepare::package': | ||
source => $source, | ||
source => $source, | ||
destination_name => $destination_name, | ||
} | ||
|
||
contain puppet_agent::prepare::package | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,45 @@ | |
creates => $local_package_file_path, | ||
require => File[$puppet_agent::params::local_packages_dir], | ||
} | ||
} elsif $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /Darwin/ { | ||
$download_username = getvar('puppet_agent::username', 'forge-key') | ||
$download_password = unwrap(getvar('puppet_agent::password')) | ||
|
||
$response_file = "${local_package_file_path}.response" | ||
$netrc_file = "${facts['env_temp_variable']}/.netrc" | ||
file { $netrc_file: | ||
ensure => file, | ||
content => "machine artifacts-puppetcore.puppet.com\nlogin ${download_username}\npassword ${download_password}\n", | ||
mode => '0600', | ||
show_diff => false, | ||
} | ||
|
||
$curl_command = "curl --fail -1 -sL --netrc-file '${netrc_file}' -w '%{http_code}' -o '${local_package_file_path}' '${source}' > '${response_file}'" | ||
exec { 'Download Puppet Agent for Darwin': | ||
command => $curl_command, | ||
creates => $local_package_file_path, | ||
path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'], | ||
} | ||
|
||
exec { 'Remove .netrc file': | ||
command => "rm -f '${netrc_file}'", | ||
path => ['/usr/bin', '/bin'], | ||
onlyif => "test -f '${netrc_file}'", | ||
require => Exec['Download Puppet Agent for Darwin'], | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may produce a "changed" event each time the agent runs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that the kind of issue https://forge.puppet.com/modules/puppetlabs/transition/readme exists for? |
||
# | ||
# TODO: This is a temporary workaround to get the HTTP response code from the curl command. | ||
# For now just outputting the response is good enough. | ||
# We need to find a way to interspect this value and fail the catalog if the response | ||
# code is not 200, and then logging the output wont be as important. | ||
# | ||
exec { 'Read HTTP Response Code': | ||
command => "cat '${response_file}'", | ||
path => ['/usr/bin', '/bin'], | ||
onlyif => "test -f '${response_file}'", | ||
logoutput => true, | ||
require => Exec['Download Puppet Agent for Darwin'], | ||
} | ||
cthorn42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
file { $local_package_file_path: | ||
ensure => file, | ||
|
Uh oh!
There was an error while loading. Please reload this page.