Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thmttch committed Apr 20, 2014
1 parent a05d215 commit 1b82b9c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#site :opscode
source "http://api.berkshelf.com"
site :opscode
#source "http://api.berkshelf.com"

metadata
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Vagrant.configure("2") do |config|
config.vm.provision :chef_solo do |chef|
chef.json = {
:anaconda => {
:version => '1.9.2'
:version => '1.8.0',
:flavor => 'x86',
}
}

Expand Down
50 changes: 21 additions & 29 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,33 @@
version = node.anaconda.version
flavor = node.anaconda.flavor
installer = "Anaconda-#{version}-Linux-#{flavor}.sh"
puts installer
Chef::Log.debug "installer = #{installer}"
debconf_template = "anaconda-debconf"
debconf_template_path = "#{Chef::Config[:file_cache_path]}/#{debconf_template}"

remote_file "#{Chef::Config[:file_cache_path]}/#{installer}" do
source "http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/#{installer}"
checksum node.anaconda.installer[version][flavor]
#notifies :run, 'bash[run anaconda installer]', :delayed
notifies :run, 'bash[run anaconda installer]', :delayed
end

bash 'run anaconda installer' do
# yes, this is nested heredocs; see below for conversation
code <<EOS
bash "#{Chef::Config[:file_cache_path]}/#{installer}" <<STDIN
#template "#{Chef::Config[:file_cache_path]}/#{installer}.debconf" do
template debconf_template_path do
source "#{debconf_template}.erb"
#owner
#group
#mode
variables({
:version => version,
:flavor => flavor,
:anaconda_install_dir => anaconda_install_dir,
:add_to_shell_path => add_to_shell_path ? 'yes' : 'no',
})
end

yes
#{anaconda_install_dir}
#{add_to_shell_path ? 'yes' : 'no'}
STDIN
EOS
action :run
bash 'run anaconda installer' do
code "cat #{debconf_template_path} | bash #{Chef::Config[:file_cache_path]}/#{installer}"
#action :run
action :nothing
not_if { File.directory?(anaconda_install_dir) }
end

=begin
The questions are:
# In order to continue the installation process, please review the license
# agreement. Please, press ENTER to continue
'',
# Do you approve the license terms? [yes|no]
'yes',
# Anaconda will now be installed into this location:
# /home/blah/anaconda
# - Press ENTER to confirm the location
# - Press CTRL-C to abort the installation
# - Or specify an different location below
anaconda_install_dir,
# Do you wish the installer to prepend the Anaconda install location to PATH in your /home/vagrant/.bashrc ? [yes|no]
add_to_shell_path ? 'yes' : 'no'
=end
14 changes: 9 additions & 5 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
end
#subject { chef_run }

it 'runs without errors; anything else is untestable. see test-kitchen tests' do
it 'runs without errors. see test-kitchen tests for more comprehensive tests not possible here' do
#default.anaconda.install_root = '/opt/anaconda'
chef_run.converge(described_recipe)

Expand All @@ -55,10 +55,14 @@
#expect(chef_run).to create_directory chef_run.node.anaconda.install_root
end

#it 'installs python' do
##should install_package 'foo'
#expect(chef_run).to include_recipe 'python::default'
#end
it 'generates the installer template correctly' do
chef_run.converge(described_recipe)

# must be exactly 4 lines
debconf_template = "anaconda-debconf"
debconf_template_path = "#{Chef::Config[:file_cache_path]}/#{debconf_template}"
expect(chef_run).to render_file(debconf_template_path).with_content(/.*\n.*\n.*\n.*/)
end

#it "creates specified users" do
##users.each { |u| expect(chef_run).to create_user u }
Expand Down
24 changes: 24 additions & 0 deletions templates/default/anaconda-debconf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%#
The questions are:
# In order to continue the installation process, please review the license
# agreement. Please, press ENTER to continue
'',
# Do you approve the license terms? [yes|no]
'yes',
# Anaconda will now be installed into this location:
# /home/blah/anaconda
# - Press ENTER to confirm the location
# - Press CTRL-C to abort the installation
# - Or specify an different location below
anaconda_install_dir,
# Do you wish the installer to prepend the Anaconda install location to PATH in your /home/vagrant/.bashrc ? [yes|no]
add_to_shell_path ? 'yes' : 'no'
%>
<%- case "#{@version}-#{@flavor}" %>
<%- when 'nothing here because no exceptions between different installers' %>
<%- else %>

yes
<%= @anaconda_install_dir %>
<%= @add_to_shell_path %>
<%- end %>

0 comments on commit 1b82b9c

Please sign in to comment.