On Wednesday, 9 July 2014 14:39:48 UTC-7, Timothy Appnel wrote:
>
> I've absolutely read over this thread and the project page. You've ported 
> the ansible module helpers to PHP so you can write your modules in PHP 
> rather than learn some Python and use what's already there.


I have written several modules in Python. I am very familiar with Python. 
That is my go-to language for just about anything. All of the problems I am 
solving with this library I have already done workarounds for either in the 
tasks (combined with other tasks usually) or in Python-based modules, but 
they are very ugly and not close to as good at reporting information back.

If some code (an Ansible module) needs to check something that is not 
readily available as a file, and non-trivial to get to in Python, I think 
the best way to get that information is by hooking in directly to that API 
compared to coming from the outside with a Python-based module, executing a 
script via command/shell (like Drush or WP-CLI as explained in my 
documentation, which sometimes give no indicators to state change; and also 
can be very slow with no chance at optimisation), or worse yet attempting 
at re-implementing any of that code in Python (which is pointless because 
all of these sites call upon 3rd party code that has to be called properly 
in order for the database to stay consistent). In terms of Drupal and 
WordPress, these are not well-designed frameworks in that sense. No one 
will disagree with that. But they still exist and people still use them. I 
simply want to provide reliable deployment with as much accurate 
information as possible, and to minimise the copy-paste of code in any 
PHP-based module.

In addition to providing an API similar to Ansible's own but in PHP, I am 
also trying to alleviate some non-obvious PHP pitfalls like error/exception 
handling (all errors call a fail_json()-like function and provide (as 
useful as possible) a backtrace) and JSON encoding (which properly calls 
json_last_error() in PHP every time). Having a 'simple' (one file) PHP 
module would be nice, but then you would have copy-paste in every module 
you create in PHP. And that would be the same case in Python if Ansible did 
not provide a library.

This would not be any different to me if a large code base was written in 
any other language, and has no Python API (or REST API) to check/change 
things (which is the case for a lot of things). I would still considering 
putting together a module in that language (or whatever works best) so I 
can get the best access to the information and give as best as possible 
feedback on changes made during deployment.

What I do not want is that just because it is some non-Python thing and/or 
cannot be reliably be managed via Python that the command/shell module says 
'"changed": true' every single time. That is generally useless especially 
if the command is actually idempotent in one way or another but Ansible 
(even with changed_when and inspecting stdout or rc) cannot detect that.

Finally, nobody is forced to use this for PHP or anything else. It is 
merely a suggestion. But it does hook into existing projects relatively 
easily, with only a few caveats. And indeed there are people out there who 
will not approach writing an Ansible module because they do not know 
Python. I do not see anything wrong with providing a tool.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/565dbfa8-d266-4e5f-81a8-989d1227fcf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to