Skip to content

Instantly share code, notes, and snippets.

@tommeier
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommeier/c00ba747171267eb5b31 to your computer and use it in GitHub Desktop.
Save tommeier/c00ba747171267eb5b31 to your computer and use it in GitHub Desktop.
Boxen puppet commands for Buildkite agent install
class people::thing_with_buildbox {
$library_dir = "${home}/Library"
$launch_dir = "${library_dir}/LaunchAgents"
$plist_location = "${launch_dir}/io.buildbox.buildbox-agent.plist"
$buildbox_token = "YOUR_TOKEN"
$buildbox_install_dir = "${home}/.buildbox"
$buildbox_log_dir = "${buildbox_install_dir}/log"
$buildbox_bin_dir = "${buildbox_install_dir}/bin"
$plist_template_url = "https://github.com/buildbox/agent/blob/master/templates/launchd_local_with_gui.plist"
$agent_name = "canary"
$agent_metadata = "name=${agent_name},ios_simulator=true"
# $plist_template_url = "https://raw.githubusercontent.com/buildbox/buildbox-agent/master/templates/launchd.plist"
if ! defined(File[$library_dir]) {
file { $library_dir:
ensure => "directory"
}
}
if ! defined(File[$launch_dir]) {
file { $launch_dir:
ensure => "directory"
}
}
notice("Downloading Buildkite latest... Please wait (this can take a while)...")
# https://buildkite.com/docs/agent/installation
# -> Using new beta for elastic builds
exec {'Install or Update Buildbox':
command => 'curl -sL https://raw.github.com/buildbox/agent/master/install.sh | BETA=true bash 2>&1',
logoutput => true,
timeout => 0
}
exec {'Stop Any Running Buildbox':
command => "launchctl unload ${plist_location} || true && rm -rf ${plist_location}",
onlyif => "test -e ${plist_location}"
}
exec {'Save Buildbox Autostart Script':
command => "rm -rf ${plist_location} && curl -o ${plist_location} ${$plist_template_url}",
creates => "${plist_location}",
require => [ File[$launch_dir], Exec['Stop Any Running Buildbox'], Exec["Install or Update Buildbox"] ]
}
exec {'Store Buildbox User In Script':
command => "sed -i '' 's/your-build-user/${::boxen_user}/g' ${plist_location}",
require => [ Exec["Save Buildbox Autostart Script"] ]
}
exec {'Store Buildbox Access Token In Script':
command => "sed -i '' 's/your-agent-access-token/${buildbox_token}/g' ${plist_location}",
require => [ Exec["Save Buildbox Autostart Script"] ]
}
exec {'Store Buildbox Agent Name In Script':
command => "sed -i '' 's/your-agent-name/${agent_name}/g' ${plist_location}",
require => [ Exec["Save Buildbox Autostart Script"] ]
}
exec {'Store Buildbox Agent Metadata In Script':
command => "sed -i '' 's/your-agent-meta-data/${agent_metadata}/g' ${plist_location}",
require => [ Exec["Save Buildbox Autostart Script"] ]
}
exec {'Update Buildbox Log Access':
command => "mkdir -p ${buildbox_log_dir} && chmod 775 ${buildbox_log_dir}",
require => [ Exec["Save Buildbox Autostart Script"], Exec["Install or Update Buildbox"] ]
}
exec {'Start Buildbox Agent':
command => "launchctl load ${plist_location}",
require => [
Exec["Store Buildbox User In Script"],
Exec["Store Buildbox Access Token In Script"],
Exec["Store Buildbox Agent Name In Script"],
Exec["Store Buildbox Agent Metadata In Script"],
Exec["Update Buildbox Log Access"],
]
}
notice("Buildkite\: a reboot is required to work correctly!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment