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

execute.WithEnvVar is not working #130

Closed rhugga closed 10 months ago

rhugga commented 1 year ago

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?

ono7 commented 1 year ago

Are you by chance using a socks proxy (macos -> proxy -> rhel) ? I had issues just like this with a socks proxy server... had to use linux, something OS releated to macos and the amount of connections made through the socks proxy.. tried tweaking the ssh proxy side but could never get it to work properly..

On Wed, Nov 15, 2023 at 11:58 AM Crashk1d @.***> wrote:

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"), ),

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? — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
apenella commented 1 year ago

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!

apenella commented 10 months ago

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

Thanks!

apenella commented 10 months ago

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.