mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-25 06:15:56 +01:00
33 lines
616 B
Go
33 lines
616 B
Go
|
package tasks
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"strconv"
|
||
|
|
||
|
"github.com/ansible-semaphore/semaphore/util"
|
||
|
)
|
||
|
|
||
|
func (t *task) installInventory() error {
|
||
|
if t.inventory.SshKeyID != nil {
|
||
|
// write inventory key
|
||
|
err := t.installKey(t.inventory.SshKey)
|
||
|
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)
|
||
|
}
|