Sha256: ea9a581c238d7339f3c5b81c94d2828bd4a9e277286e356e92b5632a8c51ac1e

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'rake'
require 'optparse'
require 'securerandom'

namespace :harmony do
  desc 'Generate a key'
  task :generate_key do
    puts SecureRandom.hex
  end

  desc 'Generate keys and create encrypted sekret files'
  task :write_secrets do |_t, _args|
    abort "ENV['QUEUE_NAME'] must be set." unless ENV['QUEUE_NAME']
    abort "ENV['STAGING_AMPQ_URL'] must be set." unless ENV['STAGING_AMPQ_URL']
    abort "ENV['PRODUCTION_AMPQ_URL'] must be set." unless ENV['PRODUCTION_AMPQ_URL']

    secrets = {
      development: { harmony_queue: ENV['QUEUE_NAME'], ampq_address: ENV['STAGING_AMPQ_URL'], ampq_vhost: 'harmony-staging-queue' },
      staging: { harmony_queue: ENV['QUEUE_NAME'], ampq_address: ENV['STAGING_AMPQ_URL'], ampq_vhost: 'harmony-staging-queue' },
      production: { harmony_queue: ENV['QUEUE_NAME'], ampq_address: ENV['PRODUCTION_AMPQ_URL'], ampq_vhost: 'harmony' }
    }

    secrets.each do |env, data|
      key = SecureRandom.hex
      `ruby -r yaml -e'puts(#{data}.to_yaml)' | sekrets write config/#{env}.yml.enc --key #{key}`
      puts "#{env}: #{key}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
harmony-service-0.8.3 lib/harmony/service/rake_tasks.rb
harmony-service-0.8.2 lib/harmony/service/rake_tasks.rb
harmony-service-0.8.1 lib/harmony/service/rake_tasks.rb
harmony-service-0.8.0 lib/harmony/service/rake_tasks.rb
harmony-service-0.7.2 lib/harmony/service/rake_tasks.rb