module Formatron::Generators::Bootstrap::Config

generates an empty config

Public Class Methods

write( directory, target = nil, protect = true, cookbooks_bucket_prefix = nil ) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/formatron/generators/bootstrap/config.rb, line 37
def self.write(
  directory,
  target = nil,
  protect = true,
  cookbooks_bucket_prefix = nil
)
  target_directory = File.join(
    directory,
    'config',
    target.nil? ? '_default' : target.to_s
  )
  FileUtils.mkdir_p target_directory
  file = File.join target_directory, '_default.json'
  write_default(file) if target.nil?
  write_target(
    file,
    target,
    protect,
    cookbooks_bucket_prefix
  ) unless target.nil?
end
write_default(file) click to toggle source
# File lib/formatron/generators/bootstrap/config.rb, line 6
        def self.write_default(file)
          File.write file, <<-EOH.gsub(/^ {12}/, '')
            {
            }
          EOH
        end
write_target(file, target, protect, cookbooks_bucket_prefix) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/formatron/generators/bootstrap/config.rb, line 14
        def self.write_target(file, target, protect, cookbooks_bucket_prefix)
          File.write file, <<-EOH.gsub(/^ {12}/, '')
            {
              "protected": #{protect},
              "bastion": {
                "sub_domain": "bastion-#{target}"
              },
              "nat": {
                "sub_domain": "nat-#{target}"
              },
              "chef_server": {
                "sub_domain": "chef-#{target}",
                "cookbooks_bucket": "#{cookbooks_bucket_prefix}-#{target}",
                "ssl": {
                  "verify": true
                }
              }
            }
          EOH
        end