community.general
community.general copied to clipboard
Add artisan module
SUMMARY
New module: Artisan command line interface
ISSUE TYPE
- New Module/Plugin Pull Request
COMPONENT NAME
community.general.artisan
ADDITIONAL INFORMATION
Artisan is the command line interface included with Laravel. This Ansible module was heavily inspired by community.general.composer, which is typically used together with artisan.
Where possible, we use specialised Ansible modules for our deployments. The built-in command module is currently used for artisan. It would be great if we could replace it with this module.
The included examples, as well as a number of edge cases, were all tested locally. Once published, we will use the module productively and further develop it.
Happy Hacking, Ralf
The test botmeta failed with 2 errors:
.github/BOTMETA.yml:0:0: Author codebarista not mentioned as active or inactive maintainer for plugins/modules/artisan.py (mentioned are: )
.github/BOTMETA.yml:0:0: No (active or inactive) maintainer mentioned for plugins/modules/artisan.py
The test licenses failed with 4 errors:
plugins/modules/artisan.py:0:0: found copyright line with "Copyright:". Please remove the colon.
plugins/modules/artisan.py:0:0: SPDX-License-Identifier yielded the license list (empty), while manual guessing yielded the license list "GPL-3.0-or-later"
plugins/modules/artisan.py:0:0: found no copyright notice
plugins/modules/artisan.py:0:0: must have at least one license
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/modules/artisan.py:25:71: W291: trailing whitespace
plugins/modules/artisan.py:26:73: W291: trailing whitespace
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/modules/artisan.py:25:71: W291: trailing whitespace
plugins/modules/artisan.py:26:73: W291: trailing whitespace
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/modules/artisan.py:25:71: W291: trailing whitespace
plugins/modules/artisan.py:26:73: W291: trailing whitespace
The test ansible-test sanity --test pep8 [explain] failed with 2 errors:
plugins/modules/artisan.py:25:71: W291: trailing whitespace
plugins/modules/artisan.py:26:73: W291: trailing whitespace
The test ansible-test sanity --test validate-modules [explain] failed with 7 errors:
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'args' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'options' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.args: Argument defines type as list but elements is not defined for dictionary value @ data['options']['args']. Got {'description': ['Command arguments, mainly in custom commands.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.options: Argument defines type as list but elements is not defined for dictionary value @ data['options']['options']. Got {'description': ['Command options like seed or force without leading hyphens.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:10:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
The test ansible-test sanity --test validate-modules [explain] failed with 7 errors:
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'args' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'options' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.args: Argument defines type as list but elements is not defined for dictionary value @ data['options']['args']. Got {'description': ['Command arguments, mainly in custom commands.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.options: Argument defines type as list but elements is not defined for dictionary value @ data['options']['options']. Got {'description': ['Command options like seed or force without leading hyphens.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:10:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
The test ansible-test sanity --test validate-modules [explain] failed with 7 errors:
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'args' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: doc-default-does-not-match-spec: Argument 'options' in argument_spec defines default as ([]) but documentation defines default as (None)
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.args: Argument defines type as list but elements is not defined for dictionary value @ data['options']['args']. Got {'description': ['Command arguments, mainly in custom commands.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.options: Argument defines type as list but elements is not defined for dictionary value @ data['options']['options']. Got {'description': ['Command options like seed or force without leading hyphens.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:10:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.args: Argument defines type as list but elements is not defined for dictionary value @ data['options']['args']. Got {'description': ['Command arguments, mainly in custom commands.'], 'required': False, 'type': 'list'}
plugins/modules/artisan.py:0:0: parameter-list-no-elements: DOCUMENTATION.options.options: Argument defines type as list but elements is not defined for dictionary value @ data['options']['options']. Got {'description': ['Command options like seed or force without leading hyphens.'], 'required': False, 'type': 'list'}
The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'args' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'options' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'args' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'options' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'args' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'options' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'args' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: doc-elements-mismatch: Argument 'options' in argument_spec does not specify elements,but elements is documented as being str
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'args' in argument_spec defines type as list but elements is not defined
plugins/modules/artisan.py:0:0: parameter-list-no-elements: Argument 'options' in argument_spec defines type as list but elements is not defined
@codebarista this PR contains the following merge commits:
- https://github.com/ansible-collections/community.general/commit/df5524ce4c54581a9dba0424d5f1bbdff667f4b3
Please rebase your branch to remove these commits.
Thanks for the detailed review and valuable tips. I took my bearings, or copied parts of it, from community.general.composer which was already added in 2014. In particular, moving the common logic to module utils and maintenance mode or a cache state make absolute sense.
The first modules with a state would then be:
- community.general.artisan_maintenance
- community.general.artisan_migration
- community.general.artisan_cache
- TBD...
I will commit your suggestions and start with the Utils. For the tests I have to do a litte more research.
Thanks for the detailed review and valuable tips.
You're welcome! And thanks for working on this!
I took my bearings, or copied parts of it, from community.general.composer which was already added in 2014.
Old modules unfortunately often tend to do things that we eventually found out aren't a good idea :) (Not that we don't sometimes repeat such mistakes in new ones...)
For the tests I have to do a litte more research.
The compose module unfortunately has no tests; you can find integration tests in tests/integration/targets/, every directory that isn't prefixed with a plugin type is for a module (or group of modules).
Hi @russoz,
thank you for your support and the helpful hints. As you might guess, Python is not my first language and code reviews are very welcome.
I also thought that it wouldn't be that easy to contribute an Ansible module. But it's definitely worth a try. :)
After Felix's review, it was clear that I had completely ignored the concept of "state" for the module. In addition to the core commands, there can theoretically be countless package commands in the Laravel cosmos.
For Ansible that would potentially mean just as many modules/plugins.
So I have already created a community.laravel collection using the Ansible template in a (currently private) GitHub repo.
The artisan module of this PR becomes a util (in module_utils) and the command modules have all their specific state and entire change messages.
Currently only the plugin structure is committed, although I would adopt the collected changes from this thread.
This PR would then be obsolete.
Do you think the collection has a chance and would you, or anyone reading this, be interested in a code review (or even contribution) when the first functions are implemented?
There was a little more time over the turn of the year, but I would try to make more progress. :)
Hi @russoz,
thank you for your support and the helpful hints. As you might guess, Python is not my first language and code reviews are very welcome.
I also thought that it wouldn't be that easy to contribute an Ansible module. But it's definitely worth a try. :)
After Felix's review, it was clear that I had completely ignored the concept of "state" for the module. In addition to the core commands, there can theoretically be countless package commands in the Laravel cosmos.
For Ansible that would potentially mean just as many modules/plugins.
So I have already created a community.laravel collection using the Ansible template in a (currently private) GitHub repo.
The artisan module of this PR becomes a util (in module_utils) and the command modules have all their specific state and entire change messages.
Currently only the plugin structure is committed, although I would adopt the collected changes from this thread.
This PR would then be obsolete.
Do you think the collection has a chance and would you, or anyone reading this, be interested in a code review (or even contribution) when the first functions are implemented?
There was a little more time over the turn of the year, but I would try to make more progress. :)
Hi @codebarista
Sorry I missed this one.
If you are still working on the collection I would be happy to help review a bit of code over there - but I at this point I would not commit to do that regularly and indefinitely. As to "the collection has a chance" I cannot honestly answer - before seeing your PR I had never heard of artisan and laravel before, and TBH I never heard of it again. 🤣 I reckon that depends on that specific community, their needs, and your ability to sell the idea of using your collection within their contexts.
As you wrote this is no longer being pursued, I will mark this PR to be closed (or feel free to go ahead and close it yourself), unless you have had a change of heart.
needs_info
Cheers, AZ
@codebarista This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.
Sorry, when I have some time I will take up the topic again, but at the moment I am stuck in project work.
