<commit_before>require 'netaddr'
require 'hiera'
require 'yaml'

set :openstack_path, "."

load "#{openstack_path}/roles.rb"
load "#{openstack_path}/output.rb"

set :proxy, "http_proxy=http://proxy:3128 https_proxy=http://proxy:3128"
set :puppet_p, "#{proxy} puppet"


# return the hash map credentials
def rc(name)
  config = YAML::load_file("#{openstack_path}/puppet/hiera/common.yaml")
  user = config["openstack::keystone::users"][name]
  if (user.nil?)
    return {}
  end

  return {
    "OS_USERNAME"            => name,
    "OS_PASSWORD"            => <PASSWORD>["password"],
    "OS_TENANT_NAME"         => user["tenant"],
    'OS_AUTH_URL'            => 'http://localhost:5000/v2.0/',
    'OS_REGION_NAME'         => 'openstack',
    'KEYSTONE_ENDPOINT_TYPE' => 'publicURL',
    'NOVA_ENDPOINT_TYPE'     => 'publicURL'
  }
end


namespace :openstack do

  desc 'Deploy openstack'
  task :default do
    init::default
    hiera::default
    sitepp::default
    fix_permissions
    run_agents::default
  end

  
  namespace :init do
    desc 'init the puppet module'   
    task :default do
      proxy 
      prepare
      patchs
    end

    # Put it in puppet recipe
    task :init, :roles => [:openstack] do
      set :user, "root"
      upload "#{openstack_path}/templates/gemrc", "/etc/gemrc", :via => :scp
      upload "#{openstack_path}/templates/proxy-guess", "/etc/apt/apt.conf.d/proxy-guess", :via => :scp
    #  upload "#{openstack_path}/templates/puppet.conf", "/etc/puppet/puppet.conf", :via => :scp
    end

    task :prepare, :roles => [:puppet_master], :on_error => :continue  do
      set :user, "root"
      run "rm -rf /etc/puppet/modules"
      # fix an issue with wrong dependency
      run "#{puppet_p} module install puppetlabs-concat -v 1.2.2" 
      run "#{puppet_p} module install puppetlabs-openstack -v 4.2.0"
      upload "#{openstack_path}/puppet/openstackg5k", "/etc/puppet/modules", :via => :scp, :recursive => :true
    end 

    desc 'Apply patches'
    task :patchs, :roles => [:puppet_master] do
      set :user, "root"
      upload "#{openstack_path}/puppet/patchs/modules", "/etc/puppet/", :via => :scp, :recursive => :true
    end
  end
<commit_msg>force puppetlabs/apt to 1.8.0<commit_after>require 'netaddr'
require 'hiera'
require 'yaml'

set :openstack_path, "."

load "#{openstack_path}/roles.rb"
load "#{openstack_path}/output.rb"

set :proxy, "http_proxy=http://proxy:3128 https_proxy=http://proxy:3128"
set :puppet_p, "#{proxy} puppet"


# return the hash map credentials
def rc(name)
  config = YAML::load_file("#{openstack_path}/puppet/hiera/common.yaml")
  user = config["openstack::keystone::users"][name]
  if (user.nil?)
    return {}
  end

  return {
    "OS_USERNAME"            => name,
    "OS_PASSWORD"            => user["password"],
    "OS_TENANT_NAME"         => user["tenant"],
    'OS_AUTH_URL'            => 'http://localhost:5000/v2.0/',
    'OS_REGION_NAME'         => 'openstack',
    'KEYSTONE_ENDPOINT_TYPE' => 'publicURL',
    'NOVA_ENDPOINT_TYPE'     => 'publicURL'
  }
end


namespace :openstack do

  desc 'Deploy openstack'
  task :default do
    init::default
    hiera::default
    sitepp::default
    fix_permissions
    run_agents::default
  end

  
  namespace :init do
    desc 'init the puppet module'   
    task :default do
      proxy 
      prepare
      patchs
    end

    # Put it in puppet recipe
    task :init, :roles => [:openstack] do
      set :user, "root"
      upload "#{openstack_path}/templates/gemrc", "/etc/gemrc", :via => :scp
      upload "#{openstack_path}/templates/proxy-guess", "/etc/apt/apt.conf.d/proxy-guess", :via => :scp
    #  upload "#{openstack_path}/templates/puppet.conf", "/etc/puppet/puppet.conf", :via => :scp
    end

    task :prepare, :roles => [:puppet_master], :on_error => :continue  do
      set :user, "root"
      run "rm -rf /etc/puppet/modules"
      # fix an issue with wrong dependency
      run "#{puppet_p} module install puppetlabs-concat -v 1.2.2" 
      run "#{puppet_p} module install puppetlabs-apt -v 1.8.0" 
      run "#{puppet_p} module install puppetlabs-openstack -v 4.2.0"
      upload "#{openstack_path}/puppet/openstackg5k", "/etc/puppet/modules", :via => :scp, :recursive => :true
    end 

    desc 'Apply patches'
    task :patchs, :roles => [:puppet_master] do
      set :user, "root"
      upload "#{openstack_path}/puppet/patchs/modules", "/etc/puppet/", :via => :scp, :recursive => :true
    end
  end

{'fraction_non_alphanumeric': 0.153088630259624, 'fraction_numerical': 0.010743061772605193, 'mean_word_length': 3.000895255147717, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7333718', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1602, 'n_words': 354}