2016-04-08 21:41:20 +02:00
|
|
|
package tasks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/ansible-semaphore/semaphore/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (t *task) installInventory() error {
|
2018-03-27 22:12:47 +02:00
|
|
|
if t.inventory.SSHKeyID != nil {
|
2016-04-08 21:41:20 +02:00
|
|
|
// write inventory key
|
2018-03-27 22:12:47 +02:00
|
|
|
err := t.installKey(t.inventory.SSHKey)
|
2016-04-08 21:41:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch t.inventory.Type {
|
|
|
|
case "static":
|
|
|
|
return t.installStaticInventory()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *task) installStaticInventory() error {
|
|
|
|
t.log("installing static inventory")
|
|
|
|
|
|
|
|
// create inventory file
|
|
|
|
return ioutil.WriteFile(util.Config.TmpPath+"/inventory_"+strconv.Itoa(t.task.ID), []byte(t.inventory.Inventory), 0664)
|
|
|
|
}
|