Example #1
0
func (t *Template) Run() error {
	defer urknall.OpenLogger(os.Stdout).Close()
	var target urknall.Target
	var err error
	if t.Password != "" {
		target, err = urknall.NewSshTargetWithPassword(t.UserName+"@"+t.Host, t.Password)

	} else {
		if len(strings.TrimSpace(t.Host)) <= 0 || t.Host == LOCALHOST {
			target, err = urknall.NewLocalTarget()
		} else {
			target, err = urknall.NewSshTarget(t.UserName + "@" + t.Host) //this is with sshkey
		}
	}
	if err != nil {
		return err
	}

	runner, err := get(t.Name)

	if err != nil {
		log.Errorf("fatal error, couldn't locate the package %s", t.Name)
		return err
	}

	if initializeRunner, ok := runner.(TemplateRunnable); ok {
		initializeRunner.Options(t)
		return initializeRunner.Run(target)
	}
	return errors.New(fmt.Sprintf("fatal error, couldn't locate the package %q", t.Name))
}
Example #2
0
func run() error {
	defer urknall.OpenLogger(os.Stdout).Close()
	var target urknall.Target
	var e error
	uri := "*****@*****.**"
	password := ""
	if password != "" {
		target, e = urknall.NewSshTargetWithPassword(uri, password)
	} else {
		target, e = urknall.NewSshTarget(uri)
	}
	if e != nil {
		return e
	}
	return urknall.Run(target, &Template{})
}