<commit_before>#
# Cookbook Name:: cookbook-openshift3
# Recipe:: wire_aggregator
#
# Copyright (c) 2015 The Authors, All Rights Reserved.

server_info = OpenShiftHelper::NodeHelper.new(node)
first_master = server_info.first_master
master_servers = server_info.master_servers
certificate_server = server_info.certificate_server
is_certificate_server = server_info.on_certificate_server?

if node['cookbook-openshift3']['encrypted_file_password']['data_bag_name'] && node['cookbook-openshift3']['encrypted_file_password']['data_bag_item_name']
  secret_file = node['cookbook-openshift3']['encrypted_file_password']['secret_file'] || nil
  encrypted_file_password = Chef::EncryptedDataBagItem.load(node['cookbook-openshift3']['encrypted_file_password']['data_bag_name'], node['cookbook-openshift3']['encrypted_file_password']['data_bag_item_name'], secret_file)
else
  encrypted_file_password = node['cookbook-openshift3']['encrypted_file_password']['default']
end

if is_certificate_server
  directory "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters" do
    mode '0755'
    owner 'apache'
    group 'apache'
  end

  execute 'Creating Master Aggregator signer certs' do
    command "#{node['cookbook-openshift3']['openshift_common_admin_binary']} ca create-signer-cert \
            --cert=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --key=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.key \
            --serial=#{node['cookbook-openshift3']['openshift_master_config_dir']}/ca.serial.txt"
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt"
  end

  # create-api-client-config generates a ca.crt file which will
  # overwrite the OpenShift CA certificate.  
  # Generate the aggregator kubeconfig and delete the ca.crt before creating archive for masters
  
  execute 'Create Master api-client config for Aggregator' do
    command "#{node['cookbook-openshift3']['openshift_common_admin_binary']} ca create-api-client-config \
            --certificate-authority=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --signer-cert=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --signer-key=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.key \
            --user aggregator-front-proxy \
            --client-dir=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters \
            --signer-serial=#{node['cookbook-openshift3']['openshift_master_config_dir']}/ca.serial.txt"
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/aggregator-front-proxy.kubeconfig"
  end
  
  file "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/ca.crt" do
    action :delete
    only_if { File.exist? "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/ca.crt" }
  end

  %w(aggregator-front-proxy.crt aggregator-front-proxy.key aggregator-front-proxy.kubeconfig).each do |aggregator_file|
    remote_file "#{node['cookbook-openshift3']['openshift_master_config_dir']}/#{aggregator_file}" do
      source "file://#{Chef::Config[:file_cache_path]}/certtemp/#{aggregator_file}"
      not_if { ::File.file?("#{node['cookbook-openshift3']['openshift_master_config_dir']}/#{aggregator_file}") }
    end
  end

  execute 'Create a tarball of the aggregator certs' do
    command "tar czvf #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz -C #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters . "
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz"
  end

  execute 'Encrypt master master tgz files' do
    command "openssl enc -aes-256-cbc -in #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz  -out #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz.enc -k '#{encrypted_file_password}' && chmod -R  0755 #{node['cookbook-openshift3']['master_generated_certs_dir']} && chown -R apache: #{node['cookbook-openshift3']['master_generated_certs_dir']}"
  end
end<commit_msg>Remove ca calls from oc adm create-api-client-config<commit_after>#
# Cookbook Name:: cookbook-openshift3
# Recipe:: wire_aggregator
#
# Copyright (c) 2015 The Authors, All Rights Reserved.

server_info = OpenShiftHelper::NodeHelper.new(node)
first_master = server_info.first_master
master_servers = server_info.master_servers
certificate_server = server_info.certificate_server
is_certificate_server = server_info.on_certificate_server?

if node['cookbook-openshift3']['encrypted_file_password']['data_bag_name'] && node['cookbook-openshift3']['encrypted_file_password']['data_bag_item_name']
  secret_file = node['cookbook-openshift3']['encrypted_file_password']['secret_file'] || nil
  encrypted_file_password = Chef::EncryptedDataBagItem.load(node['cookbook-openshift3']['encrypted_file_password']['data_bag_name'], node['cookbook-openshift3']['encrypted_file_password']['data_bag_item_name'], secret_file)
else
  encrypted_file_password = node['cookbook-openshift3']['encrypted_file_password']['default']
end

if is_certificate_server
  directory "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters" do
    mode '0755'
    owner 'apache'
    group 'apache'
  end

  execute 'Creating Master Aggregator signer certs' do
    command "#{node['cookbook-openshift3']['openshift_common_admin_binary']} ca create-signer-cert \
            --cert=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --key=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.key \
            --serial=#{node['cookbook-openshift3']['openshift_master_config_dir']}/ca.serial.txt"
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt"
  end

  # create-api-client-config generates a ca.crt file which will
  # overwrite the OpenShift CA certificate.  
  # Generate the aggregator kubeconfig and delete the ca.crt before creating archive for masters
  
  execute 'Create Master api-client config for Aggregator' do
    command "#{node['cookbook-openshift3']['openshift_common_admin_binary']} create-api-client-config \
            --certificate-authority=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --signer-cert=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.crt \
            --signer-key=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/front-proxy-ca.key \
            --user aggregator-front-proxy \
            --client-dir=#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters \
            --signer-serial=#{node['cookbook-openshift3']['openshift_master_config_dir']}/ca.serial.txt"
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/aggregator-front-proxy.kubeconfig"
  end
  
  file "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/ca.crt" do
    action :delete
    only_if { File.exist? "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters/ca.crt" }
  end

  %w(aggregator-front-proxy.crt aggregator-front-proxy.key aggregator-front-proxy.kubeconfig).each do |aggregator_file|
    remote_file "#{node['cookbook-openshift3']['openshift_master_config_dir']}/#{aggregator_file}" do
      source "file://#{Chef::Config[:file_cache_path]}/certtemp/#{aggregator_file}"
      not_if { ::File.file?("#{node['cookbook-openshift3']['openshift_master_config_dir']}/#{aggregator_file}") }
    end
  end

  execute 'Create a tarball of the aggregator certs' do
    command "tar czvf #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz -C #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters . "
    creates "#{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz"
  end

  execute 'Encrypt master master tgz files' do
    command "openssl enc -aes-256-cbc -in #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz  -out #{node['cookbook-openshift3']['master_generated_certs_dir']}/wire_aggregator-masters.tgz.enc -k '#{encrypted_file_password}' && chmod -R  0755 #{node['cookbook-openshift3']['master_generated_certs_dir']} && chown -R apache: #{node['cookbook-openshift3']['master_generated_certs_dir']}"
  end
end
{'fraction_non_alphanumeric': 0.14507943512797883, 'fraction_numerical': 0.010150044130626656, 'mean_word_length': 6.076502732240437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3278151', 'n_tokens_mistral': 3090, 'n_tokens_neox': 2935, 'n_words': 368}