lindegroup / autopkgr

AutoPkgr is a free Mac app that makes it easy to install and configure AutoPkg.
http://www.lindegroup.com/autopkgr
Apache License 2.0
532 stars 51 forks source link

How does AutoPkgr treat JAMF Cloud hosted JSS? #170

Closed acodega closed 9 years ago

acodega commented 9 years ago

I'm looking to integrate AutoPkgr with my JSS, which is hosted by JAMF Cloud.

Therefore, my JSS url is https://jss.jamfcloud.com/[myinstance]/

Initial username/password configuration is failing. In the verbose logs you'll find:

10/25/14 1:51:48.091 PM AutoPkgr[2221]: [DEBUG] Got authentication challenge 10/25/14 1:51:48.206 PM AutoPkgr[2221]: [DEBUG] Response: <NSHTTPURLResponse: 0x6000002305a0> { URL: https://jss.jamfcloud.com/JSSResource/distributionpoints } { status code: 404, headers { Connection = "keep-alive"; "Content-Length" = 442; "Content-Type" = "text/html"; Date = "Sat, 25 Oct 2014 17:51:48 GMT"; Server = Apache; } } 10/25/14 1:51:48.207 PM AutoPkgr[2221]: Error: Request failed: not found (404) 10/25/14 1:51:48.207 PM AutoPkgr[2221]: [DEBUG] Error [404]: Resource not found The requested resource could not be found. Please make sure you've entered the correct protocol, hostname, and port.

I believe the URL AutoPkgr should be trying to access is: https://jss.jamfcloud.com/[myinstance]/JSSResource/distributionpoints

Does anyone else use AutoPkgr with a JAMF Cloud hosted JSS?

eahrold commented 9 years ago

@acodega Thanks so much for reporting this. We have a somewhat limited number of JSS setups we tested on and the cloud instance I have actually has a FQDN and consequently no /[instance name]/ in the path...

Good news is I know exactly what's happening and how to fix it. I should be able to get a build up for testing later tonight or tomorrow.

If you find any other issues, let us know.

Thanks again, --Eldon

eahrold commented 9 years ago

@acodega I just put up a build on my forks page. https://github.com/eahrold/autopkgr/releases/tag/1.1.1-bugfix

Would you mind testing it out on your server and letting me know if I works with the jss cloud instance.

@homebysix can you give it a test drive on your machines and let me know if anything breaks.

Thanks. --Eldon

acodega commented 9 years ago

@eahrold It works! Awesome!

I think I'm going to have to wait until I'm in office to test interaction with JSS and uploading to my distribution points.

eahrold commented 9 years ago

Hey Adam, ( @acodega ), I wanted to check back with you and see if you've had a chance to test this out yet?

Thanks.

acodega commented 9 years ago

I can connect to the JSS and it asks for the DP read/write password, so looks like that part is all set with your fix. Thanks!

Right now I'm trying a Firefox package and I'm getting "jss.jss.JSSGetError:JSS Error, Response Code: 404 Response", I will take a look at the logs later. Unfortunately doesn't look like I took good enough notes from the talk last week.

eahrold commented 9 years ago

@acodega do you have the full traceback of the error?

acodega commented 9 years ago

Here's the log:

10/29/14 9:53:32.024 AM AutoPkgr[4728]: [DEBUG] Completed AutoPkg Task: /usr/bin/python /usr/local/bin/autopkg version 10/29/14 9:53:33.455 AM AutoPkgr[4728]: (1/4) Processing Firefox.jss... 10/29/14 9:56:33.999 AM AutoPkgr[4728]: [DEBUG](FULL AUTOPKG TRACEBACK) Traceback (most recent call last): File "/usr/local/bin/autopkg", line 1334, in sys.exit(main(sys.argv)) File "/usr/local/bin/autopkg", line 1328, in main exit(subcommands[verb]'function') File "/usr/local/bin/autopkg", line 1152, in run_recipes autopackager.process(recipe) File "/Library/AutoPkg/autopkglib/init.py", line 466, in process self.env = processor.process() File "/Library/AutoPkg/autopkglib/init.py", line 295, in process self.main() File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 571, in main ssl_verify=sslVerify, repo_prefs=repos) File "/Library/Python/2.7/site-packages/jss/jss.py", line 166, in init self.distribution_points = distribution_points.DistributionPoints(self) File "/Library/Python/2.7/site-packages/jss/distribution_points.py", line 58, in init self.response = j.DistributionPoint().retrieve_all() File "/Library/Python/2.7/site-packages/jss/jss.py", line 314, in DistributionPoint return self.factory.get_object(DistributionPoint, data) File "/Library/Python/2.7/site-packages/jss/jss.py", line 451, in get_object result = self.jss.get(url) File "/Library/Python/2.7/site-packages/jss/jss.py", line 199, in get self._error_handler(JSSGetError, response) File "/Library/Python/2.7/site-packages/jss/jss.py", line 186, in _error_handler raise exception jss.jss.JSSGetError: JSS Error. Response Code: 404 Response" 10/29/14 9:56:33.999 AM AutoPkgr[4728]: [DEBUG] Error [140735305239808] Error running recipes jss.jss.JSSGetError: JSS Error. Response Code: 404 Response" 10/29/14 9:56:34.000 AM AutoPkgr[4728]: [DEBUG] Nothing new was downloaded. /usr/bin/python /usr/local/bin/autopkg run --recipe-list /Users/swipelyhoopla/Library/Application Support/AutoPkgr/recipe_list.txt --report-plist /var/folders/rj/pt6mms8n3t7fy2rm696_kbnw0000gn/T/2973AADA-AD24-4B72-B4B7-BD97EF0990AB-4728-00008F564F08A52E

acodega commented 9 years ago

Also, I think people could use some clarification, if we're on a brand new setup, do we need anything else besides the .jss?

eahrold commented 9 years ago

If you're on a completely new machine, you should only need install Git, AutoPkg, and the JSS-AutoPkg-Addon. AutoPkgr should handle all of this for you. After that the rest is configured on the JSS Server itself using the steps outlined in the Integration with Casper section here https://github.com/lindegroup/autopkgr.

######## Back to diagnostics ######## what do you get when you do

defaults read com.github.autopkg JSS_URL

I want to make sure AutoPkgr actually appended [your instance] name to the URL.

Also we've go a key that will run AutoPkg verbosely (essentially append the -v key to the run)

defaults write com.lindegroup.AutoPkgr verboseAutoPkgRun -bool True

Turn that on, it should print out more processor information.

Do you feel comfortable coding python?

If so add this line to /Library/Python/2.7/site-packages/jss/jss.py at line 194

print ("This is the response from the JSS-Server !! -- %s" % response.text.encode('utf-8'))

It should tell us exactly what is happening and why the 404 error is occurring.

Thanks for the help figuring this out, --Eldon

acodega commented 9 years ago

I mean for recipes, do we just select the jss recipe? No .install needed?

I will run these commands and get you info soon.

eahrold commented 9 years ago

Correct, as long as the you have the repo added where the ParentRecipe is there's no need to add the .install recipe itself.

Thanks I also opened an issue about this on the python-jss page so you can keep an eye on that too.

https://github.com/sheagcraig/python-jss/issues/2

eahrold commented 9 years ago

Hey Adam ( @acodega ), Did you ever have a chance to put that line into the jss.py and get some results?

If it's what I suspect is happening, I should be able to put up a pull request to https://github.com/sheagcraig/python-jss

We tracked down another issue in that project today, and I'd love to tackle them both at once.

acodega commented 9 years ago

This sounds great, had another super busy day today but I did run

defaults read com.github.autopkg JSS_URL

And the proper instance URL is returned.

I can work my way through editing Python so I'll edit that line as instructed. I bet it will get us the output we want.

eahrold commented 9 years ago

@acodega I wanted to follow up again and see whether you were able to get any results. I'd like to get a 1.1.1 bufix update out soon, and this is on the list of things to check-off.

--Eldon

acodega commented 9 years ago

So it looks like the 404 happens at the start of JSSImporter but I'm not sure what it's trying to retrieve from the server. I was able to make the verbose output and Python code change.

11/3/14 9:00:29.228 AM AutoPkgr[53204]: JSSImporter
11/3/14 9:00:29.898 AM AutoPkgr[53204]: This is the response from the JSS-Server !! -- <html><head><title>Apache Tomcat/7.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Not Found</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Not Found</u></p><p><b>description</b> <u>The requested resource (Not Found) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.26</h3></body></html>
11/3/14 9:00:29.957 AM AutoPkgr[53204]: [DEBUG] (FULL AUTOPKG TRACEBACK) Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1334, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1328, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1152, in run_recipes
    autopackager.process(recipe)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 466, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 295, in process
    self.main()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 571, in main
    ssl_verify=sslVerify, repo_prefs=repos)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 166, in __init__
    self.distribution_points = distribution_points.DistributionPoints(self)
  File "/Library/Python/2.7/site-packages/jss/distribution_points.py", line 58, in __init__
    self.response = j.DistributionPoint().retrieve_all()
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 314, in DistributionPoint
    return self.factory.get_object(DistributionPoint, data)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 451, in get_object
    result = self.jss.get(url)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 199, in get
    self._error_handler(JSSGetError, response)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 186, in _error_handler
    raise exception
jss.jss.JSSGetError: JSS Error. Response Code: 404  Response" 
11/3/14 9:00:29.958 AM AutoPkgr[53204]: [DEBUG] Error [140735154200448] Error running recipes 
 jss.jss.JSSGetError: JSS Error. Response Code: 404 Response" 
11/3/14 9:00:29.959 AM AutoPkgr[53204]: [DEBUG] Nothing new was downloaded.
11/3/14 9:00:29.959 AM AutoPkgr[53204]: [DEBUG] Completed AutoPkg Task:
  /usr/bin/python /usr/local/bin/autopkg run --recipe-list /Users/swipelyhoopla/Library/Application Support/AutoPkgr/recipe_list.txt --report-plist /var/folders/rj/pt6mms8n3t7fy2rm696_kbnw0000gn/T/E3279F1C-71BD-4E08-B87C-46D4FCD191AA-53204-00017CE05FAA0922 -v
eahrold commented 9 years ago

Damn! On most of there servers I use "(Not Found)" would actually tell you what was not found in the `This is the response from the JSS-Server !!``

The requested resource (Not Found) is not available.

I'm not sure where to go from here, It looks like the python-jss has a new release, so the jss-autopkg-addon is not far behind. Hopefully a number of these issues will get worked out there.

If you feel like delving in deeper into the code, just go and put in some print() lines following back this traceback so the next place I would try to get more information would be here line 451 in the jss.py

  File "/Library/Python/2.7/site-packages/jss/jss.py", line 451, in get_object
    result = self.jss.get(url)

figuring out what it's using for the url so at Line 450 something like this (although it may need encoding applied(

print("USING THIS URL %s",url)

The biggest bummer is my JSS cloud trial just expired so I'm not able to test or run any casper integration stuff, so all I'm able to do now is point you in a direction.

Thanks, --Eldon

acodega commented 9 years ago

I'll be glad to help debug further, my schedule can be a little hectic but I'll see what I can do with your latest post tomorrow morning.

eahrold commented 9 years ago

@acodega We just realized there is really strange behavior with JAMF's redirection, and I can't get anything to work around it, but the good news is it may be as simple as this...

instead of using a URL like this

https://jss.jamfcloud.com/acodega

try this one...

https://acodega.jamfcloud.com
acodega commented 9 years ago

Will report on this tomorrow @eahrold

acodega commented 9 years ago

So this is interesting.

My Mac mini was hosed, so I rebulit it and had to reinstall AutoPkgr 1.1 beta and the dependencies. Did something change on one of them? This what I get now for an error when trying to process apps. I have only Firefox.jss and Firefox.pkg checked off.

11/14/14 2:39:30.712 PM AutoPkgr[428]: [DEBUG] Completed AutoPkg Task: /usr/bin/python /usr/local/bin/autopkg version 11/14/14 2:39:31.246 PM AutoPkgr[428]: (1/2) Processing Firefox.pkg... 11/14/14 2:39:44.291 PM AutoPkgr[428]: (2/2) Processing Firefox.jss... 11/14/14 2:39:59.198 PM AutoPkgr[428]: [DEBUG] Error [1] Error running recipes mount_smbfs: server connection failed: Connection refused Traceback (most recent call last): File "/usr/local/bin/autopkg", line 1334, in <module> sys.exit(main(sys.argv)) File "/usr/local/bin/autopkg", line 1328, in main exit(subcommands[verb]['function'](argv)) File "/usr/local/bin/autopkg", line 1152, in run_recipes autopackager.process(recipe) File "/Library/AutoPkg/autopkglib/__init__.py", line 466, in process self.env = processor.process() File "/Library/AutoPkg/autopkglib/__init__.py", line 295, in process self.main() File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 591, in main self.package = self.handle_package() File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 295, in handle_package self.j.distribution_points.mount() File "/Library/Python/2.7/site-packages/jss/distribution_points.py", line 117, in mount child.mount() File "/Library/Python/2.7/site-packages/jss/distribution_points.py", line 206, in mount subprocess.check_call(args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 542, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['mount', '-t', 'smbfs', u'//CasperAdmin:********@192.168.60.9:139/CasperShare', '/Volumes/SwipeITCasperShare']' returned non-zero exit status 68 11/14/14 2:39:59.199 PM AutoPkgr[428]: [DEBUG] Nothing new was downloaded. 11/14/14 2:39:59.199 PM AutoPkgr[428]: [DEBUG] Completed AutoPkg Task: /usr/bin/python /usr/local/bin/autopkg run --recipe-list /Users/macadmin/Library/Application Support/AutoPkgr/recipe_list.txt --report-plist /var/folders/b3/jxplz2091hz9qb16wg962_4c0000gn/T/09567317-1940-4E2A-A756-D17F5B31A6C9-428-00000035294E1D74

eahrold commented 9 years ago

This is excellent, it seems like your other issue is fixed and this is a known issue and has to do with special characters in the password. See https://github.com/lindegroup/autopkgr/issues/177

This should be solved upstream in the python-jss in an upcoming release, but for now you need to figure out what the encoded string would be and enter that into the "API Password" area.

BTW did changing the URL work for you?

acodega commented 9 years ago

My API user does not have special characters in it's password.

Changing the URL does NOT work. If you enter https://[instance].jamfcloud.com/ into a browser it redirects you but it won't work in AutoPkgr 1.1

eahrold commented 9 years ago

That's funny. For us it works exactly the opposite way. We enter https://jss.jamfcloud.com/[instance] and it redirects to https://[instance].jamfcloud.com/

Actually it has nothing to do with the API user. It's about the user and password for the SMB share point.

long story short this is failing when doing the python equivalent of this in the shell

mkdir  /Volumes/SwipeITCasperShare
mount -t smbfs //CasperAdmin:xxxxx@192.168.60.9:139/CasperShare /Volumes/SwipeITCasperShare

If you can get that to work the rest should fall into place.

acodega commented 9 years ago

Oh, the other user! Okay that makes sense.

I changed that password and it's still failing with the same error. Shouldn't this line have backslash?

'/Volumes/SwipeITCasperShare' Should be.. '/Volumes/SwipeIT/CasperShare'

eahrold commented 9 years ago

No, that's the way python-jss insures it's not colliding with a previously mounted fs, you can mkdir any name you want as long as you have that as the last argument to the mount command.

Looking closer at the exception too, it does appear to be some other issue (the password issue was returning a -1609 error). This could be about the port or url scheme. Double check and see how the dp is set up in you JSS, and make sure you can get to it via port 139. OSX will try and access it via tcp using port 445 by default. You may need to override that if testing using Finder to connect to server.

eahrold commented 9 years ago

@acodega Just figured out what the 68 error is you're seeing is. I did this to a server I knew I couldn't reach due to a firewall blocking port 139 but allowing 445

computer:~ eldon$ mkdir /Volumes/jss
computer:~ eldon$ mount -t smbfs //jssadmin:mypass@jss.smbserver.com:139/JSS /Volumes/jss :echo ExitStatus: $?
mount_smbfs: server connection failed: Operation timed out
ExitStatus 68

computer:~ eldon$ mount -v -t smbfs //jssadmin:mypass@jss.smbserver.com::445/JSS /Volumes/jss ; echo ExitStatus$?
//jssadmin@jss.smbserver.com::445/JSS on /Volumes/jss (smbfs, nodev, nosuid, mounted by jssadmin)
ExitStatus 0

What OS is your DP running on?

acodega commented 9 years ago

My DP runs on a Mac mini running 10.9.5, it's also the Mac that AutoPkgr runs on.

eahrold commented 9 years ago

That's you're culprit. I don't believe that configuration is supported currently since python-jss wants to do a remote mount. This is an issue for https://github.com/sheagcraig/python-jss and Shea is super open to new ideas, put up an issue there. But for now for testing if you move your DP over to another machine I think you'll be off to the races.

eahrold commented 9 years ago

But also if the machine you move the dp to is a mac make sure to set the port to 445 in your jss.

homebysix commented 9 years ago

You can run AutoPkgr on the same Mac as your DP, but if you do that I'd recommend using the old JSS_REPO key instead of the new JSS_REPOS key.

And then you'll need to rely on some other mechanism for keeping your DPs in sync. A scheduled rsync job works well.

eahrold commented 9 years ago

Right so

defaults write com.github.autopkg JSS_REPO /path/to/local/folder

And you'll also need to remove the JSS_REPOS key or the JSS_REPO will be overridden

defaults delete com.github.autopkg JSS_REPOS
homebysix commented 9 years ago

Correction:

defaults delete com.github.autopkg JSS_REPOS
eahrold commented 9 years ago

Either actually work.

eahrold commented 9 years ago

@homebysix but you're right, looks like remove is undocumented, must be depreciated.

eahrold commented 9 years ago

@acodega, Hey Adam, I'm going to close this issue since the scope has changed. using the JSS_REPO key (singular) and manually removing the plural version, should work on your problem. If interested you should open up a Feature Request issue suggesting that AutoPkgr build in the ability to set this key.

Again thanks for you help on this. --Eldon