-
Notifications
You must be signed in to change notification settings - Fork 38
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
Script uploaded to JSS not populating #19
Comments
Can you post your jss recipe (scrubbed for personal info of course), as well as your ScriptTemplate.xml that you specify in the recipe? That would give me a good start. I assume you're not getting any errors in AutoPkg, right? |
No errors in AutoPkg, it says it uploaded the script and/or updated it. I just launched Casper Admin and it says the script is missing and not Stored in Database. JSS Recipe - https://github.com/golbiga/recipes/blob/master/JSS/TextMate2.jss.recipe |
Hmmm. Recipe and template look good. What kind of distribution points are you using? |
smb distribution point |
I suspect the .txt thing is not coming from python-jss/JSSImporter. (But from where? No clue!) The fact that you're getting the red missing script text in Casper Admin means that there should be a script object created for it, but either the file is missing, or it is not replicated across all distribution points. Do you have more than one SMB distribution point, and if so, are they all configured in your com.github.autopkg.plist? I'll keep looking through the code to see if I can come up with any other ideas. |
Another thing you could check is to hit the API for the list of scripts and see what it reports for TextMate2Preinstall.sh. If you're not already digging around with python-jss, easiest way would be to go the /api page on your JSS and just hit the Scripts get button and confirm the script object exists. Then use the ID from that to GET the specific script and double-check that it looks as expected. You could compare to one that you already have too. |
Only a single DP at the moment. |
Can see the script from the /api page, but the contents are empty there as well. I'm guessing when you import it's supposed to take the contents of the script and combine with the template? Other scripts when brought have the actual script content when i look them up by id. |
So that's weird. On our JSS (9.61...) the "script_contents" are empty for ALL scripts. You're saying that some of your scripts, when you look at them through the API, have the actual code in the object? With a SMB (and AFP) DP, I'm pretty sure it just defers to the file specified in the "filename" field. Once you have "migrated" your server to using a JDS (as mentioned in the "JDS Instances" page of Computer Management, you then have all of your script text included in the script_contents field. So my guess it that something is jacked up because you have migrated your system to using the DB style storage for the packages and scripts. With a SMB DP configured, JSSImporter is trying to copy the script file, but the JSS ignores it because it really wants it to be in the database. This is not a situation that I had foreseen! A few things:
Otherwise, I'll probably have to add in some kind of override key or something that allows you to do this. |
JSS is 9.6, recently migrated/upgraded from 8.73. Post migration I hit the migration button so all flat pkgs were zipped up and scripts copied to database. Not using a JDS. I just checked a bunch of scripts using GET /scripts/id/{id} and they all had the actual code. This includes scripts that were added post migration to v9. Packages work just fine, other JSS recipes work perfectly. |
Okay, that's almost certainly it then. python-jss/JSSImporter don't handle that correctly then. Did you try the "JDS" trick above?
|
Is this what you mean? "JSS_REPOS" = ( |
Close, but remove the SMB DP configuration. The only element of the array should be the "type = JDS". This will use the same mechanism to upload scripts and packages that JDS' use. The package likely won't work that way, but I just want to see if the script will work. If you already have a package object with the current name JSSImporter will skip it. |
Ok, removed the SMB DP configuration and only had "type = JDS", same results. |
Dang. I'll have to add in something to handle this for sure then. Until then, you'll have to manually do the script stuff for this policy. Each JSSImporter run will probably replace the script_contents, which could get irritating! |
Here's one more question, to help me write the code to handle this. On your SMB share, do you have a Scripts subdirectory, and if so, does it have the script files in it? |
It does and guess what, the script is there. Maybe if I remove the Scripts folder? It will write to the database instead of trying to write to DP? |
Oh right, but you said that the file is empty? Or it's just empty in the DB Are all of your other scripts in there? Or just the JSSImported one? |
Only scripts that were there pre jss migration/upgrade (moved from os x server to rhel plust 8.73 to 9.6). Newer ones are not there. Which makes me think I could remove that folder? |
If you have a backup... Give it a go. Then give the JDS thing a try again. Make sure you manually erase the script object in the JSS->Computer Management->Scripts page first. Just to be safe. |
Actually, hold on. I'm working on my SketchUp recipe, and it requires a script (don't get me started...) And I'm getting the same thing, only we haven't migrated. There's no script file on the SMB share. So maybe there is something going on in the code that I missed previously. |
Ok, I'm going to find out as well If I can remove the Scripts folder since their technically in the database now. |
I got the OK from JAMF to remove the Scripts folder. When I did that and ran the TextMate2 recipe I get this error when it gets to the point of copying the script. |
Tried the JDS trick, empty script uploaded but no errors. |
Okay, that's as to be expected. You can't shutil.copy to a nonexistent folder. It's super weird about how the scripts are just empty. I think that this means that we have to add the script to the script object rather than upload the script file. |
Does that require a change to the code or just a section added to the script template? |
This will require some changes to the code. I'm thinking that a global "JSS_MIGRATED" flag will be added. As far as I can tell so far, the only time this affects anything is when a script is uploaded (as packages still work, right?) I'll need to add mostly documentation. The JSSImporter will need a block to handle JSS_MIGRATED in the handle_scripts() method. Basically, if the JSS has been migrated, it will have to add the contents of the script file to the XML to be POSTed as part of the script object, rather than as a discrete file to be stored in the SMB shares' Scripts folder. I'm hoping I can test this on our test server, as it has been migrated so we can use a JDS; but it also has a SMB share. I'll let you know when the testing version drops so you can test it out for me. |
@golbiga I have this "working". It has thrown my object hierarchy into a tizzy, so I'm contemplating how to refactor and restructure to make it "make sense". But it does indeed work. |
@sheagcraig I'm still having issues post upgrade. It's still trying to copy the script to a distribution point and not to the database. I added JSS_MIGRATED true to com.github.autopkg.plist If /data/caspershare/Scripts exists the script is copied there but is blank in the JSS and shows up as missing. If /data/caspershare/Scripts is removed i get the following: JSSImporter: Script: TextMate2Preinstall.sh created. I tried the JDS trick but it simply adds a blank TextMate2Preinstall.sh file as well. Thanks |
Hey @golbiga! Based on the traceback, I think I see what is happening. The very last bit mentions the copy is using shutil.copyfile, which should not be the case here. It should be using AFP and SMB repos can be configured with just the share's "name" and password. The rest of the information to connect is pulled from the Distribution Points API call. As it stands, the And the conditions I check for are whether a So I'm guessing you didn't divine the magical incantation! This is primarily a documentation issue, but also a python-jss vs. JSSImporter issue. I'm going to add in some code to pass the correct data around for the auto-detection scheme mentioned above so you don't have to add anything extra into your config. Only people who are explicitly configuring AFP and SMB shares outside of the DistributionPoints class will ever need to worry about this, and it is documented in the docstring. Just to see it "work" and confirm that this methodology works, you can give this a try:
e.g.:
If you get it wrong, curl and the JSS will often give you a response of "Success", even though nothing happened. You'll know it worked because
Can I slip you a testing version once I get it updated? That way I can release again with the comfort of knowing that it works correctly! |
Yeah-try grabbing |
Just swapped out distribution_points.py and the scripts are now being uploaded properly. Thanks! |
Phew! I'm glad that works. I've got a PR to review; after that I'll push a release. Thanks for bringing to my attention. |
I've also got this problem. I've set JSS_MIGRATED to True but it is still "copying" the script to the distribution point:
It cannot really be copying it, because I do not have a Scripts folder - this is a new setup built originally as 9.100, so there's never been a scripts folder. But still, Casper Admin shows the script as "missing" and there is an empty script object in the database. I'm using the default way of setting up the JSSImporter settings. Is there some other value that has to be set?
|
@grahampugh are you using or testing the JSSImporter testing release? It should solve this issue (it does away with the |
Hi Shea
Yes we started using that and it works well. Is that release now the one that your AutoPkg recipe points to?
PS your JSSImporter came up a LOT in JNUC this year. I’m very interested in helping extend its functionality to the new Patch Policies, which will be separately populated. I guess it needs a new Processor.
Cheers
Graham
… On 26 Oct 2017, at 14:12, Shea Craig ***@***.***> wrote:
@grahampugh <https://github.com/grahampugh> are you using or testing the JSSImporter testing release? It should solve this issue (it does away with the JSSI_MIGRATED value entirely.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#19 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFiK5c97Ln29fNsXUmitEn-SLC5HtUx7ks5swNmdgaJpZM4DJoeM>.
|
When adding a script to a jss.recipe the contents of the script are not showing up in the JSS. The script itself is there, but the script contents are empty. In the RECIPE_DIR is the script and app specific scripttemplate.xml. The actual jss.recipe has the appropriate fields added for scripts.
When I try to download the script from within the JSS GUI it's downloading the file with filename.sh.txt and the contents of that file are empty. Not sure if I'm doing something wrong here.
Thanks
Allen
The text was updated successfully, but these errors were encountered: