summaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/compile.rb
blob: 429d1c5b2c18996767dd6900a29266c52475a96b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

module LeapCli
  module Commands

    desc 'Compile json files to hiera configs'
    command :compile do |c|
      c.action do |global_options,options,args|
        manager.load(Path.provider)
        ensure_dir(Path.hiera)
        manager.export(Path.hiera)
        update_authorized_keys
        update_known_hosts
      end
    end

    def update_authorized_keys
      buffer = StringIO.new
      Dir.glob(named_path(:user_ssh, '*')).each do |keyfile|
        buffer << File.read(keyfile)
      end
      write_file!(:authorized_keys, buffer.string)
    end

  end
end