Class: VagrantPlugins::Solidus::Provisioner

Inherits:
Object
  • Object
show all
Includes:
SiteHelpers
Defined in:
lib/vagrant-solidus/provisioner.rb

Constant Summary

Constants included from SiteHelpers

SiteHelpers::BASE_PORT, SiteHelpers::BASE_UTILS_PORT, SiteHelpers::DEFAULT_NODE_VERSION, SiteHelpers::DEFAULT_NPM_VERSION, SiteHelpers::PROVISION_ID, SiteHelpers::SITE_STATUS_WATCHER_POLLING_FREQUENCY, SiteHelpers::SITE_TEMPLATE_GIT_TAG, SiteHelpers::SITE_TEMPLATE_GIT_URL

Instance Method Summary collapse

Methods included from SiteHelpers

#build_site, #clone_site_template, #create_site_from_template, #directory_exists?, #fail, #find_port, #follow_site_log, #guest_exec, #help_command_line_option, #host_exec, #install_pow_site, #install_site_dependencies, #install_site_node, #install_site_node_packages, #install_site_service, #ip_address, #load_site, #log, #log_callback, #log_site_log_tail, #log_site_urls, #node_command, #node_version, #npm_version, #pow_installed?, #provisioned!, #provisioned?, #quiet_command_line_option, #save_site, #set_site_ports, #site_commands_arguments, #site_name_command_line_option, #site_responding?, #site_service_name, #site_start_command_line_options, #site_started?, #site_template_command_line_options, #site_watcher_service_name, #sites, #solidus_server_service_name, #start_site_service, #start_site_watcher, #stop_site, #stop_site_service, #uninstall_pow_site, #uninstall_site_service, #validate_site, #wait_for_site_watcher_to_stop, #wait_until_guest_directory_exists, #with_log, #with_mutex

Instance Method Details

#configure(root_config) ⇒ Object



6
7
8
9
10
# File 'lib/vagrant-solidus/provisioner.rb', line 6

def configure(root_config)
  (root_config.solidus.site_ports + root_config.solidus.livereload_ports + root_config.solidus.log_server_ports).each do |port|
    root_config.vm.network :forwarded_port, guest: port, host: port
  end
end

#provisionObject



12
13
14
15
16
17
18
19
20
21
22
23
24
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vagrant-solidus/provisioner.rb', line 12

def provision
  # ***********************************************************************
  # !! IMPORTANT !! Update SiteHelpers::PROVISION_ID when this method is
  #                 changed, to force a re-provisioning.
  # ***********************************************************************

  @env = @machine.env

  @env.ui.info('Retrieving new lists of packages')
  execute('apt-get update', sudo: true)

  @env.ui.info('Installing curl')
  execute('apt-get -y install curl', sudo: true)

  @env.ui.info('Installing vim')
  execute('apt-get -y install vim', sudo: true)

  @env.ui.info('Installing git')
  execute('apt-get -y install git', sudo: true)

  @env.ui.info('Installing dos2unix')
  execute('apt-get -y install dos2unix', sudo: true)

  @env.ui.info('Installing nvm')
  execute('curl -s -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.1/install.sh | bash')
  unless guest_exec(nil, 'grep NVM_DIR ~/.profile')
    execute('echo \'export NVM_DIR="/home/vagrant/.nvm"\' >> ~/.profile')
    execute('echo \'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm\' >> ~/.profile')
  end

  # Install a default node.js version, it will be used for grunt-init and when ssh'ing into the box
  @env.ui.info('Installing node.js')
  execute("nvm install #{DEFAULT_NODE_VERSION}")
  execute("nvm use #{DEFAULT_NODE_VERSION}")
  execute("nvm alias default #{DEFAULT_NODE_VERSION}")

  @env.ui.info('Installing npm')
  execute("npm install npm@'#{DEFAULT_NPM_VERSION}' -g")

  @env.ui.info('Installing grunt-init')
  execute('npm install grunt-init@"~0.3.1" -g')

  @env.ui.info('Configuring rubygems')
  @machine.communicate.upload(File.expand_path('provisioner/.gemrc', File.dirname(__FILE__)), '/home/vagrant/.gemrc')
  execute('dos2unix -o ~/.gemrc')

  @env.ui.info('Installing rvm and ruby')
  execute('gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3')
  execute('curl -sSL https://get.rvm.io | bash -s stable --ruby=1.9.3-p545')
  execute('source ~/.rvm/scripts/rvm')
  execute('rvm rvmrc warning ignore allGemfiles')
  execute('rvm use --default ruby-1.9.3-p545')

  @env.ui.info('Installing bundler')
  execute('gem install bundler')

  @env.ui.info('Updating libstdc++')
  execute('apt-get -y install python-software-properties', sudo: true)
  execute('add-apt-repository -y ppa:ubuntu-toolchain-r/test', sudo: true)
  execute('apt-get update', sudo: true)
  execute('DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade', sudo: true)

  @env.ui.info('Configuring bash')
  @machine.communicate.upload(File.expand_path('provisioner/.bashrc', File.dirname(__FILE__)), '/home/vagrant/.bashrc-vagrant-solidus')
  execute('dos2unix -o ~/.bashrc-vagrant-solidus')
  unless guest_exec(nil, 'grep "^\. ~/.bashrc-vagrant-solidus" ~/.bashrc')
    execute('echo ". ~/.bashrc-vagrant-solidus" >> ~/.bashrc')
    execute('. ~/.bashrc-vagrant-solidus')
  end

  execute(provisioned!)

  # ***********************************************************************
  # !! IMPORTANT !! Update SiteHelpers::PROVISION_ID when this method is
  #                 changed, to force a re-provisioning.
  # ***********************************************************************
end