Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

manage /etc/apt/sources.list on intrepid, all packages depend on running

apt-get update
  • Loading branch information...
commit 4bf74e271f1e63f42db0f8dc47f4383902cb5655 1 parent aba6706
@jnewland authored
View
3  .gitignore
@@ -9,4 +9,5 @@ spec/generator.log
.ginger
.rvmrc
.bundle
-.DS_Store
+.DS_Store
+tmp
View
3  lib/moonshine/capistrano_integration.rb
@@ -117,7 +117,6 @@ def self.load_into(capistrano_config)
desc 'Apply the Moonshine manifest for this application'
task :apply, :except => { :no_release => true } do
- aptget.update
sudo "RAILS_ROOT=#{latest_release} DEPLOY_STAGE=#{ENV['DEPLOY_STAGE'] || fetch(:stage)} RAILS_ENV=#{fetch(:rails_env)} shadow_puppet #{latest_release}/app/manifests/#{fetch(:moonshine_manifest)}.rb"
end
@@ -435,7 +434,7 @@ def self.load_into(capistrano_config)
namespace :aptget do
task :update do
- run 'if test `lsb_release -rs` != 8.10; then sudo apt-get update; fi'
+ sudo 'apt-get update'
end
end
end
View
2  lib/moonshine/manifest/rails.rb
@@ -53,7 +53,7 @@ def default_stack
self.class.recipe :sqlite3
end
recipe :rails_rake_environment, :rails_gems, :rails_directories, :rails_bootstrap, :rails_migrations, :rails_logrotate
- recipe :ntp, :time_zone, :postfix, :cron_packages, :motd, :security_updates
+ recipe :ntp, :time_zone, :postfix, :cron_packages, :motd, :security_updates, :apt_sources
end
def rails_template_dir
View
29 lib/moonshine/manifest/rails/os.rb
@@ -88,12 +88,41 @@ def security_updates
:content => template(File.join(File.dirname(__FILE__), "templates", "unattended_upgrades.erb"))
end
+ def apt_sources
+ if ubuntu_intrepid?
+ file '/etc/apt/sources.list',
+ :ensure => :present,
+ :mode => '644',
+ :content => template(File.join(File.dirname(__FILE__), "templates", "sources.list.intrepid"))
+ exec 'apt-get update', :command => 'apt-get update', :require => file('/etc/apt/sources.list')
+ else
+ exec 'apt-get update', :command => 'apt-get update'
+ end
+ end
+
+ # Override the shadow_puppet package method to inject a dependency on
+ # exec('apt-get update')
+ def package(*args)
+ if args && args.flatten.size == 1
+ super(*args)
+ elsif
+ name = args.first
+ hash = args.last
+ hash[:require] = Array(hash[:require]).push(exec('apt-get update'))
+ super(name, hash)
+ end
+ end
+
private
def ubuntu_lucid?
Facter.lsbdistid == 'Ubuntu' && Facter.lsbdistrelease.to_f == 10.04
end
+ def ubuntu_intrepid?
+ Facter.lsbdistid == 'Ubuntu' && Facter.lsbdistrelease.to_f == 8.10
+ end
+
def distro_unattended_security_origin
case Facter.lsbdistrelease.to_f
when 8.10 then 'Ubuntu intrepid-security'
View
8 lib/moonshine/manifest/rails/templates/sources.list.intrepid
@@ -0,0 +1,8 @@
+deb http://old-releases.ubuntu.com/ubuntu intrepid main restricted universe multiverse
+deb-src http://old-releases.ubuntu.com/ubuntu intrepid main restricted universe multiverse
+
+deb http://old-releases.ubuntu.com/ubuntu intrepid-updates main restricted universe multiverse
+deb-src http://old-releases.ubuntu.com/ubuntu intrepid-updates main restricted universe multiverse
+
+deb http://old-releases.ubuntu.com/ubuntu intrepid-security main restricted universe multiverse
+deb-src http://old-releases.ubuntu.com/ubuntu intrepid-security main restricted universe multiverse
View
40 lib/moonshine/matchers.rb
@@ -40,22 +40,52 @@ module Matchers
end
end
+ define :require_resource do |expected|
+ expected = Array(expected)
+ resource_string = expected.map { |r| "#{r.type.downcase}('#{r.title}')"}.join(',')
+ actual_string = ''
+
+ match do |resource|
+ resources = Array(resource.require)
+ actual_string = resources.flatten.map { |r| "#{r.type.downcase}('#{r.title}')"}.join(',')
+
+ if expected.length > resources.length
+ false
+ else
+ expected.each do |expected_resource|
+ result &&= resources.flatten.detect do |actual_resource|
+ actual_resource.type == expected_resource.type &&
+ actual_resource.title == expected_resource.title
+ end
+ end
+ end
+ end
+
+ description do
+ "should require all of #{resource_string}"
+ end
+
+ failure_message_for_should do |actual|
+ "expected resource to require all of #{resource_string}, but required #{actual_string}"
+ end
+
+ failure_message_for_should_not do |actual|
+ "expected resource not to require #{resource_string}, but required #{actual_string}"
+ end
+ end
+
define :have_package do |expected|
match do |manifest|
package = manifest.packages[expected]
result = !package.nil?
if @version
result &&= package.ensure == @version
- end
+ end
if @provider
@actual_provider = package.provider
result &&= @actual_provider == @provider.to_sym
end
- if @before
- @before.each do |type, names|
- end
- end
result
end
View
45 spec/moonshine/manifest/os_spec.rb
@@ -19,6 +19,21 @@
)
end
+
+ specify "#apt_sources injects a dependency on apt-get update" do
+ @manifest.apt_sources
+
+ @manifest.should exec_command('apt-get update')
+
+ @manifest.should_not have_file("/etc/apt/sources.list")
+
+ @manifest.package('foo', :ensure => :installed)
+
+ @manifest.packages['foo'].should require_resource(@manifest.exec('apt-get update'))
+
+ @manifest.execs['apt-get update'].should_not require_resource(@manifest.file('/etc/apt/sources.list'))
+
+ end
end
context "Ubuntu Intrepid (8.10)" do
@@ -35,6 +50,36 @@
)
end
+ specify "#apt_sources installs customized sources.lst and injects a dependency on it" do
+ @manifest.apt_sources
+
+ @manifest.should exec_command('apt-get update')
+
+ @manifest.execs['apt-get update'].should require_resource([
+ @manifest.file('/etc/apt/sources.list')
+ ])
+
+ @manifest.should have_file("/etc/apt/sources.list").with_content(
+ /deb http:\/\/old-releases.ubuntu.com\/ubuntu intrepid main restricted universe multiverse/
+ )
+
+ @manifest.package('foo', :ensure => :installed)
+ @manifest.package('too', :ensure => :installed)
+ @manifest.package('bar', :ensure => :installed, :require => @manifest.package('foo'))
+ @manifest.package('baz', :ensure => :installed, :require => [@manifest.package('foo'), @manifest.package('too')])
+
+ @manifest.packages['foo'].should require_resource(@manifest.exec('apt-get update'))
+ @manifest.packages['bar'].should require_resource([
+ @manifest.package('foo'),
+ @manifest.exec('apt-get update')
+ ])
+ @manifest.packages['baz'].should require_resource([
+ @manifest.package('foo'),
+ @manifest.package('too'),
+ @manifest.exec('apt-get update')
+ ])
+ end
+
end
specify "#security_update" do

0 comments on commit 4bf74e2

Please sign in to comment.
Something went wrong with that request. Please try again.