-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minion error when calling custom execution module from salt master #41891
Comments
@KyleMoser the code is here: Line 588 in 31d51e7
Cursory look tells me that kwarg is also a keyword so you probably don't want to use that when calling it in your code. |
@yagnik Thanks. I also tried calling it like |
can you elaborate on your example? You show If i use what I think is your test case I see expected behavior. Custom execution module: backup.py
from python interpreter
And i see in the minion log:
|
@Ch3LL I apologize for wasting your time, I was really tired yesterday and I totally screwed up my explanation. I still think there is an issue with either the documentation, or with how kwargs are passed from the salt master to the salt minion. I have edited the original post to explain the error better. I will explain again here and attempt to be more specific: My module is called backup.py and my function looks like this:
I am running a python script on my salt master, and I have a dictionary called post. 'Post' is actually a dictionary containing some key/value pairs, where one of the pairs is a key called 'fields' with a value that is another dictionary. If I run the following, it works, meaning it prints out my dictionary (which has some string key/val pairs as well as another embedded dictionary inside it): Whereas if I run the following, there are no errors, but my dictionary is nowhere to be seen in the output: And if I run the following, I get an error "Passed invalid arguments to backup.sync: sync() takes exactly 0 arguments (9 given)": Note: I never thought the above would work, I am just including it for completeness. I did, however, think using One final example, if I run the following, there are no errors, but my url and url2 are nowhere to be seen in the output:
In summary, the reason for this bug report is that it is not clear how to pass kwargs to a function. The documentation makes it seem like it can be done, but unless my understanding of Python is incorrect (and I am very new to Python so it's possible), the 'normal' way of passing kwargs simply does not work. Thanks again for taking a look at this. |
Description of Issue/Question
Salt master does not properly pass arguments to minion execution module when calling
LocalClient
. I've created a function with the following codedef example(**kwargs):
and is in a file called backup.py.and I'm calling it from python code on the salt master that looks like:
I've also tried
I've tried calling it tons of different ways. I have a dictionary called 'post' that contains some key/value pairs and contains another dictionary nested inside it. I would like to pass 'post' from the salt master to the salt minion. The documentation implies that **kwargs (e.g., any additional args you pass to the cmd function like my two examples above) will be passed to the execution module as kwargs but that does not happen
Solution:
I did, however, find a solution. I just call it like this
c.cmd(sys.argv[1], 'backup.example', kwarg=dict)
. Then the entire dict gets sent to the minion execution module, although it is strangely duplicated.###_ Setup
Custom execution module in the _modules directory.
Versions Report
Salt master is 2016.11.5 (Carbon) minion is 2016.11.4
The text was updated successfully, but these errors were encountered: