Skip to content
Discussion options

You must be logged in to vote

You can add _success_exit_codes=[0,1] which will allow the command to succeed, but there doesn't seem to be a way to get the exit code of the command.

Seems the best option is to handle the exit code in the command itself, eg

    x = host.get_fact(
        server.Command,
        f"podman secret exists {key} && echo {key} || true"
    )
    if x != None:
        print(f"{key} does exist")
    else:
        print(f"{key} did not exist")

Note that podman secret exists outputs nothing, ever, behaviour may be different if a command outputs nothing to stdout but does write to stderr where checking for None may not work.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rktjmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant