Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Remove dependency on bash #265

Closed
kljensen opened this issue Feb 9, 2020 · 2 comments · Fixed by #266
Closed

Remove dependency on bash #265

kljensen opened this issue Feb 9, 2020 · 2 comments · Fixed by #266

Comments

@kljensen
Copy link
Contributor

kljensen commented Feb 9, 2020

I am using this project on OpenBSD target systems where bash is not installed in the default system. /bin/bash is used in two places in the code base. One is the selinux specific code and the other is in hardening.yaml on line 11. Bash is used to get the ssh version

I'd like to eliminate the dependency on bash or perhaps get the ssh version in a POSIX compliant manner.

The q command in sed can set an exit code, but not on OpenBSD. It wasn't obvious to me how to remove this dependency, otherwise I would have submitted a pull request. I imagine that Ansible, which of course is using python, would be able to do this without reliance on bash. The ksh shell on OpenBSD does not support set -o pipefail.

Not that this is helpful, but in the absence of bash, this is the exception that is raised

fatal: [myhost]: FAILED! => {
    "changed": false,
    "cmd": "/bin/bash -c 'set -o pipefail && ssh -V 2>&1 | sed -r '\"'\"'s/.*_([0-9]*\\.[0-9]).*/\\1/g'\"'\"''",
    "invocation": {
        "module_args": {
            "_raw_params": "set -o pipefail && ssh -V 2>&1 | sed -r 's/.*_([0-9]*\\.[0-9]).*/\\1/g'",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": "/bin/bash",
            "removes": null,
            "stdin": null,
            "warn": true
        }
    },
    "msg": "[Errno 2] No such file or directory",
    "rc": 2
}
@kljensen
Copy link
Contributor Author

kljensen commented Feb 9, 2020

And, I want to say I'm very grateful for the hard work of the contributors to this project. Thank you!

@rndmh3ro
Copy link
Member

rndmh3ro commented Feb 9, 2020

Thanks for raising this and thanks for the kind words!

The reliance on bash and pipefail was introduced in this PR: c6ff1d3
Mainly to make ansible-lint happy.

I'd be happy to remove the dependency on these, provided ansible-lint stays happy and of course the functionality stays the same. Making ansible-lint with an exclusion of the rule happy is fine for me.

Do you want to create a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants