Class: VarsCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ukku/vars_command.rb

Instance Method Summary collapse

Instance Method Details

#execute(args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ukku/vars_command.rb', line 2

def execute(args)
  data = YAML.load_file(UKKU_FILE)
  name, server = data.first
  if name.nil?
    raise "No application configured. Run 'ukku configure <host>' first."
  end

  if data.length > 1
    if args['--app'].empty?
      raise "No app specified, use the --app NAME option"
    else
      name = args[--app]
      sever = data[name]
    end
  end

  host = server['host']
  user = server['user']
  identity_file = server['identity_file']

  conn = Connection.new(host, user, identity_file)
  conn.execute("sudo mkdir -p /etc/ukku/vars && FILES=/etc/ukku/vars/*; for f in $FILES; do echo \"${f##*/}=$(<$f)\"; done")
end