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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

execute.WithEnvVar is not working

rhugga opened this issue · comments

I have an interactive tool that uses curses based tty output and uses this library under the hood. I'm trying to suppress the various warnings ansible throws so this doesn't pollute the tty output...

I have the following:

	cmd := &playbook.AnsiblePlaybookCmd{
		Exec: execute.NewDefaultExecute(
			execute.WithWrite(io.Writer(callback)),
			execute.WithEnvVar("ANSIBLE_PYTHON_INTERPRETER", "auto_silent"),
			execute.WithEnvVar("ANSIBLE_DEPRECATION_WARNINGS", "false"),
			execute.WithEnvVar("ANSIBLE_ACTION_WARNINGS", "false"),
			execute.WithEnvVar("ANSIBLE_RETRY_FILES_ENABLED", "false"),
		),
<SNIP>

But I sporadically get the following warning on random hosts each time.

    doing x...      OK
    doing y...       OK
    doing z...                          [WARNING]: Failed to reset connection:Control socket
connect(/Users/user/.ansible/cp/9e5cbf4416): No such file or directory
OK

The tool is being run from macos clients and the remote hosts are all rhel8/9.

Anyone have any ideas?

Hi @rhugga
Thanks for raising that!
I'm not a MacOS user, so I can't reproduce the behaviour you described. However, I'll do my best to help you :)

Did you check what @ono7 said?
I wonder if it happens when executing the Ansible command without the go-ansible library because the connection is established by Ansible.

Can you validate that, please?

Thank you and thanks to @ono7 for your response!

Hi @rhugga!
Did you have the chance to validate if the issue is reproduced by executing the Ansible command directly?

Thanks!

Due to the lack of activity, I will be closing this issue. If there are any further questions or if the matter needs revisiting, please feel free to reopen or start a new issue. Thank you.