apenella / go-ansible

Go-ansible is a Go package that enables the execution of ansible-playbook or ansible commands directly from Golang applications. It supports a wide range of options for each command, enabling smooth integration of Ansible functionality into your projects.
MIT License
905 stars 143 forks source link

about ansible.cfg #79

Closed LoveXayah closed 2 years ago

LoveXayah commented 2 years ago

while i worked on this project,i find it doens't run ansible-playbook as i think,i change ansible.cfg log_path,but the go-ansible's log doesn't record ansible's output there. i read the code but don't find any config about log,does the execute.WithWrite work? here's code file,err:= os.OpenFile("xayah.log",os.O_RDWR | os.O_CREATE | os.O_APPEND,0766)

playbook := &playbook.AnsiblePlaybookCmd{
    Playbooks:         []string{"xayah.yml"},
    ConnectionOptions: ansiblePlaybookConnectionOptions,
    Options:           ansiblePlaybookOptions,
    Exec: execute.NewDefaultExecute(
        execute.WithTransformers(
            results.Prepend("Go-ansible example"),
        ),
        execute.WithWrite(file),
    ),
    StdoutCallback: "json",
}

just find that does't work.

apenella commented 2 years ago

Hi @LoveXayah I need to understand want you mean... Would you want to write the ansible-playbook output to a file or is the log_path what you want to configure? On your snipped, you are writing the ansible-playbook output into a file.

go-ansible does not manage ansible configuration. You could try to update the configuration log-path by including log-path env var on your code.

Thanks!

apenella commented 2 years ago

hi @LoveXayah there is any update about it?

apenella commented 2 years ago

@LoveXayah since there is no activity on this issue, I close it.