0

I've been trying to use the Ansible Python API as explained in their official docs here. The problem is, when I call main() Ansible returns an error saying:

the connection plugin '<class 'ansible.utils.sentinel.Sentinel'>' was not found

I'm running ansible-base version 2.10.8.

I've been stuck with this for two days now. I saw someone with the same issue over at Ansible's github page here and it seems like they don't even support their own Python API.

Can anyone suggest how I could solve this problem?

9
  • 3
    it seems they don't support their own Python API => in the notes on the top of the documentation you l linked in your very first paragraph: This API is intended for internal Ansible use. Ansible may make changes to this API at any time that could break backward compatibility with older versions of the API. Because of this, external use is not supported by Ansible Commented Apr 17, 2021 at 6:56
  • 1
    Since you asked for a suggestion: don't use the ansible internal python API in your external project. Commented Apr 17, 2021 at 6:58
  • Yes. I am aware of that and I did try working with ansible-runner first. However, ansible-runner returns a set of nested dictionaries with ansible result inside the stdout key. It's not exactly what I need. Is this to say that using the actual API is hopeless? Commented Apr 17, 2021 at 6:58
  • Yes well I have already tried the ansible-runner solution. Commented Apr 17, 2021 at 6:59
  • 2
    Ok so that's what I thought: we are in an X/Y problem. Change the stdout callback to what suits your needs. Some info here docs.ansible.com/ansible/latest/plugins/callback.html . See also this answer: stackoverflow.com/a/50017860/9401096 Commented Apr 17, 2021 at 6:59

1 Answer 1

3

I fixed my problem but it took me a few days and lots of debugging. For reasons which I will not discuss here (my tech-lead kind of forced me), I had to use this API. I recommend not using it at all outside Ansible development. It was a time consuming and bad experience in general.

This error is masking the real issue. If you see this exception it means something is broken somewhere else. It is usually inside task_executor.py. Check your code and make sure you have no typos and all arguments are provided. Python API seems to lack correct exception handling and hence the exception messages are somewhat confusing.

For me it was because I didn't provide context.CLIARGS with verbosity argument which is also missing from the brief example provided in the Ansible docs.

Sign up to request clarification or add additional context in comments.

2 Comments

Good point IMHO is pointed here stackoverflow.com/a/63939935/6709058
Thank you. At the time that I asked this question, I also read this post. It was great and gave me a better idea but after a point you're really on your own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.