Class: Cyclid::API::Plugins::Ubuntu
- Inherits:
-
Provisioner
- Object
- Base
- Provisioner
- Cyclid::API::Plugins::Ubuntu
- Defined in:
- app/cyclid/plugins/provisioner/ubuntu.rb
Overview
Ubuntu provisioner
Class Method Summary collapse
-
.metadata ⇒ Object
Plugin metadata.
Instance Method Summary collapse
-
#prepare(transport, buildhost, env = {}) ⇒ Object
Prepare an Ubuntu based build host.
Methods inherited from Provisioner
Methods inherited from Base
author, config?, config_schema, default_config, get_config, homepage, human_name, license, register_plugin, set_config, update_config, version
Class Method Details
Instance Method Details
#prepare(transport, buildhost, env = {}) ⇒ Object
Prepare an Ubuntu based build host
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/cyclid/plugins/provisioner/ubuntu.rb', line 25 def prepare(transport, buildhost, env = {}) transport.export_env('DEBIAN_FRONTEND' => 'noninteractive') # Build hosts may require an update before anything can be installed success = transport.exec('apt-get update -qq', sudo: true) raise 'failed to update repositories' unless success if env.key? :repos # Ensure apt-add-repository is available transport.exec('apt-get install -qq -y software-properties-common', sudo: true) env[:repos].each do |repo| next unless repo.key? :url # Check if it's a PPA, or a traditional repository url = repo[:url] match = url.match(/\A(ppa|http|https):.*\Z/) next unless match case match[1] when 'ppa' add_ppa_repository(transport, url) when 'http', 'https' add_http_repository(transport, url, repo, buildhost) end end # We must update again to cache the new repositories success = transport.exec('apt-get update -q', sudo: true) raise 'failed to update repositories' unless success end if env.key? :packages success = transport.exec( \ "apt-get install -q -y #{env[:packages].join(' ')}", \ sudo: true ) raise "failed to install packages #{env[:packages].join(' ')}" unless success end rescue StandardError => ex Cyclid.logger.error "failed to provision #{buildhost[:name]}: #{ex}" raise end |