Closed aogier closed 5 years ago
I would match against the kernel grain, and write a new module, that is compatible with the linux useradd module, so that it can still be used with the user state.
Thanks! Daniel
Hello Daniel, thank you for the feedback. From your answer I understand you'd go with another __virtual__
module that implement a user state interface synology-specific.
However, I cannot let it "win" over useradd implementation because latter match is still too large and win because Synology also have kernel=Linux, or maybe I'm not able to find a deterministic method to let one win over the other.
Apart user-provided virtual module override feature, given that Synology is a "first class citizen" on Saltstack (see here and here) I'd like to code that diversion for an eventual upstream merge.
What do you think ? Many thanks, ciao !
That sounds good to me!
On Mon, Aug 7, 2017 at 7:29 AM, Alessandro Ogier notifications@github.com wrote:
Hello Daniel, thank you for the feedback. From your answer I understand you'd go with another virtual module that implement a user state interface synology-specific. However, I cannot let it "win" over useradd implementation because latter match is still too large and win https://github.com/saltstack/salt/blob/82582f0304683fbc9bd35a89eca5ddf52d91419c/salt/modules/useradd.py#L40 because Synology also have kernel=Linux, or maybe I'm not able to find a deterministic method to let one win over the other. Apart user-provided virtual module override feature https://docs.saltstack.com/en/latest/ref/modules/#virtual-function, given that Synology is a "first class citizen" on Saltstack (see here https://github.com/saltstack/salt/blob/82582f0304683fbc9bd35a89eca5ddf52d91419c/salt/grains/core.py#L1135 and here https://github.com/saltstack/salt/blob/82582f0304683fbc9bd35a89eca5ddf52d91419c/salt/grains/core.py#L1511) I'd like to code that diversion for an eventual upstream merge.
What do you think ? Many thanks, ciao !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/42739#issuecomment-320663467, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssoZTCJlyigpPnxGXfCMoDtjhO8_Mnks5sVxEigaJpZM4Otii1 .
Hi, I've just implemented group/useradd for Synology platforms, relevant integration tests are passing.
I've however encountered a couple of issue I'd like to implement in a salty way:
utils
package (see for example here and here) but I cannot understand how to access __salt__
magic variable from there. Tried various solutions but no luck so faruser.rename
"root" parameters get ignored on AIX platform. It is the correct way to cope with that, or better to explicitly tell that platform does not support a particular state parameter ?Thank you, ciao !
__salt__
is not available in __utils__
You can see what is loaded in each module by checking salt.loader
https://github.com/saltstack/salt/blob/2017.7/salt/loader.py#L341
As for point 2, I don't think there is really any guidelines except that you should make sure to make a note of it in the docstring for the function. Whichever way you think is best.
ok thank you, I'm beginning to understand this magic. Still, there's another problem (this time I think real) accessing those dunders: taking as an example this line I've wrote a simple condition that checks for the 'os_family' grain. After many failed jenkins tests because KeyError I've placed a debug print and a divide by zero (you can see it here), here's the output on jenkins: grains is an empty dict.
This lead to a couple issues:
system
== True :P Can you help me please ? Many thanks !
I think the __virtual__
function may be run twice. Once before the __grains__
dict is populated, and once after, so you may try using __grains__.get('os_family')
instead so that there isn't a stack trace?
Just a thought.
the strange thing is that getting kernel
grain during __virtual__ does not seem to raise any exception (and it works, in fact, since module win group
virtual name). When I get os_family
in add() implementation I need it, but maybe this quirk is only test related ?
thank you !
That is odd. I can't think of a reason for it.
On Tue, Aug 22, 2017 at 9:05 AM, Alessandro Ogier notifications@github.com wrote:
the strange thing is that getting kernel grain during virtual does not seem to raise any exception https://github.com/aogier/salt/blob/ad2aae429c03de3d24022e6b87d87dcf88bf0088/salt/modules/groupadd.py#L33 (and it works, in fact, since module win group virtual name). When I get os_family in add() implementation I need it, but maybe this quirk is only test related ?
thank you !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/42739#issuecomment-324055538, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssodtO1D_uoOudmWNZsd5265AYH_asks5sau46gaJpZM4Otii1 .
Ok, first of all I'll try to reproduce aganist a vanilla develop branch by just implementing an integration test that should fail because no grains on already existing code. Then we will see :)
ahh, that would do it!
On Wed, Aug 23, 2017 at 8:35 AM, Alessandro Ogier notifications@github.com wrote:
I looked in the wrong place, failing tests are unit not integrations and the culprit is grains patching like here https://github.com/saltstack/salt/blob/b3aa9ab394a0028cc59a2d38d902f4136f6f869f/tests/unit/modules/test_groupadd.py#L38 or here https://github.com/saltstack/salt/blob/b3aa9ab394a0028cc59a2d38d902f4136f6f869f/tests/unit/modules/test_groupadd.py#L130. I'll add Synology support and we should be ok !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/42739#issuecomment-324354667, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssoV2IUXohWrBUZDmgxnmWSmwg52v2ks5sbDjHgaJpZM4Otii1 .
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Description of Issue/Question
Hi, on a Synology NAS I cannot manage users with
user
virtual module because nouseradd
command is present. While the installed version is pretty old, it does seem the same on develop branch.I'd be happy to implement it, but I'm not sure on which choice between patch current module and writing a new would be better given that current useradd virtual match is quite large, matching against kernel grain. What do you think ?
Thank you, regards
Steps to Reproduce Issue
Versions Report