Sha256: a118ef0fc5196c95a1ec2dc32133d7197fd290a0d151c3978722473cb020653b

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

namespace :katello do

  namespace :reset_backends do
    service_stop = "sudo /sbin/service %s status > /dev/null && sudo /sbin/service %s stop"
    service_start = "sudo /sbin/service %s start"

    task :pulp do
      SERVICES = %w(httpd pulp_workers pulp_resource_manager pulp_celerybeat)
      system(service_stop.gsub("%s", "mongod"))

      SERVICES.each{|s| system(service_stop.gsub("%s", s)) }
      system("sudo rm -rf /var/lib/mongodb/pulp_database*")
      system(service_start.gsub("%s", "mongod"))
      sleep(10)
      fail "Cannot migrate pulp database" unless system("sudo -u apache /usr/bin/pulp-manage-db")
      SERVICES.each{|s| system(service_start.gsub("%s", s)) }
      puts "Pulp database reset."
    end

    task :candlepin do
      tomcat = File.exist?('/var/lib/tomcat') ? 'tomcat' : 'tomcat6'

      system(service_stop.gsub("%s", tomcat))
      system("sudo /usr/share/candlepin/cpdb --drop --create")
      system(service_start.gsub("%s", tomcat))
      puts "Candlepin database reset."
    end
  end

  desc "Resets Foreman/Katello development environemnt. WARNING: This will destroy all your Foreman and Katello data."
  task :reset_backends do
    Rake::Task['katello:reset_backends:candlepin'].invoke
    Rake::Task['katello:reset_backends:pulp'].invoke
  end

  task :reset => ['environment'] do
    ENV['SEED_ADMIN_PASSWORD'] ||= 'changeme'
    ENV['SEED_ORGANIZATION'] ||= 'Default Organization'
    ENV['SEED_LOCATION'] ||= 'Default Location'
    Rake::Task['katello:reset_backends'].invoke
    Rake::Task['db:drop'].invoke
    Rake::Task['db:create'].invoke

    # Otherwise migration and seeds fail because they require a reloaded environment
    system('rake db:migrate')
    system('rake db:seed')
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-3.0.2 lib/katello/tasks/setup.rake
katello-3.0.1 lib/katello/tasks/setup.rake
katello-3.0.0 lib/katello/tasks/setup.rake
katello-3.0.0.rc7 lib/katello/tasks/setup.rake
katello-3.0.0.rc5 lib/katello/tasks/setup.rake
katello-3.0.0.rc4 lib/katello/tasks/setup.rake
katello-3.0.0.rc3 lib/katello/tasks/setup.rake
katello-3.0.0.rc2 lib/katello/tasks/setup.rake
katello-3.0.0.rc1 lib/katello/tasks/setup.rake