diff --git a/Berksfile b/Berksfile index 0e89e8b..935460d 100644 --- a/Berksfile +++ b/Berksfile @@ -1,4 +1,4 @@ -#site :opscode -source "http://api.berkshelf.com" +site :opscode +#source "http://api.berkshelf.com" metadata diff --git a/Vagrantfile b/Vagrantfile index 7dce289..2262b86 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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', } } diff --git a/recipes/default.rb b/recipes/default.rb index ffef20a..14163e8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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 < 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 diff --git a/spec/default_spec.rb b/spec/default_spec.rb index d918e3a..8d401c8 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -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) @@ -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 } diff --git a/templates/default/anaconda-debconf.erb b/templates/default/anaconda-debconf.erb new file mode 100644 index 0000000..b90429b --- /dev/null +++ b/templates/default/anaconda-debconf.erb @@ -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 %>