3 ms·
I wish Ansible was just a python API. Past a certain point it would be much simpler. "Its supposed to be state and not a procedure" is BS in my experience. Whe
by tryptophan 4y ago
I wish Ansible was just a python API.
Past a certain point it would be much simpler.
"Its supposed to be state and not a procedure" is BS in my experience. When you need to do IFs, load vars, do things in order anyways...it stops being a state declaration.
- athorax 4y agoThat is exactly what it is though. The Ansible CLI is just a client of that API. You can easily interface with the library itself in python
- bvrmn 4y agoAFAIK Ansible core operates in terms of tasks and plays. The only API it provides is how to construct a list of tasks and how to execute it. One has no remote state/vars at the construction time and has to use "when" or shell logic at execution time as in YAML.
- zach_garwood 4y agoCheck out pyinfra: https://pyinfra.com/ https://pyinfra.com/ I've been been using it for a couple personal projects, and I really like it.
- bvrmn 4y agoI've tried to move large ansible playbooks to pyinfra and there is no any benefit in the end. pyinfra is also "state"-oriented and for complex cases with logic you have to perform some acrobatics. IMHO switch resulted in the same mess as ansible playbooks. Note: I am python-fanatic with 15y experience.
- ameixaseca 4y agoWhat do you mean by "state-oriented"? Also: complex cases will likely result in complex code. Do you have a viable alternative for this?
- bvrmn 4y agohttps://docs.pyinfra.com/en/2.x/getting-started.html#state-definitions https://docs.pyinfra.com/en/2.x/getting-started.html#state-d... > Do you have a viable alternative for this? My imperative Fabric 1k line deploy scripts in the past allowed to encapsulate complexity because I had remote state on hands.
- kevincox 4y agoI feel the same way. I feel that I am basically writing shell scripts, but in YAML (and a nice library of idempotent functions). I think Python or she'll would be superior. And if your tool is inferior to shell scripts you are really doing something wrong.
- 7sigma 4y agoTry pulumi https://www.pulumi.com/docs/intro/languages/python/ https://www.pulumi.com/docs/intro/languages/python/