Outside of the plugin APIs, none of the python code of ansible-core should be considered a public API. Effectively, in practice that means that the ability to run any of the functionality of the ansible CLIs is not supported by any public API.
➤ python3 test.py
Starting galaxy collection install process
Nothing to do. All requested collections are already installed. If you want to reinstall them, consider using `--force`.
Starting galaxy role install process
- downloading role 'php', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-php/archive/6.0.0.tar.gz
- extracting geerlingguy.php to /home/mark/.config/ansible/roles/geerlingguy.php
- geerlingguy.php (6.0.0) was installed successfully