by gnosek · 2y ago · 0 comments
This looks like infinity times better than Ansible in some cases and somewhat worse in others (python.call every time I'd need to access a previous operation's result feels clunky, though I certainly understand why it works that way).
Do you think it would be possible to use Ansible modules as pyinfra operations? As in, for example:
- name: install foo
apt:
pkg: foo
state: present
could be available as: from pyinfra import ansible
ansible(name='install foo').apt(pkg='foo', state='present')
where the `ansible` function itself would know nothing about apt, just forward everything to the Ansible module.Note 1: I know pyinfra has a way to interface with apt, this is just an example :) Note 2: It's just my curiosity, my sysadmin days are long gone now.
Alternatively you could just yield ansible cli and execute from the local machine using the @local connector.
DISCOVERING the available ansible actions is the JFC since, like all good things python, it depends on what's currently on the PYTHONPATH and what makes writing or using any such language-server some onoz
And this wasn't what you asked, but ansible has a dedicated library for exec, since the normal `ansible` and `ansible-playbook` CLIs are really, really oriented toward interactive use: https://github.com/ansible/ansible-runner#readme