summaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/deploy.rb
blob: c5efed5de0c83a0ff1b48a784cd56998e979128e (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
26
27
28
29
module LeapCli
  module Commands

    desc 'Apply recipes to a node or set of nodes'
    long_desc 'The node filter can be the name of a node, service, or tag.'
    arg_name '<node filter>'
    command :deploy do |c|
      c.action do |global_options,options,args|
        nodes = manager.filter!(args)
        if nodes.size > 1
          say "Deploying to these nodes: #{nodes.keys.join(', ')}"
          unless agree "Continue? "
            quit! "OK. Bye."
          end
        end
        leap_root = '/root/leap'
        ssh_connect(nodes) do |ssh|
          ssh.leap.mkdir_leap leap_root
          ssh.leap.rsync_update do |server|
            node = manager.node(server.host)
            {:source => Path.named_path([:hiera, node.name]), :dest => "#{leap_root}/config/#{node.name}.yaml"}
          end
          ssh.apply_puppet
        end
      end
    end

  end
end