sheagcraig / jss-recipes

Recipes for adding autopkg software to the JSS using JSSImporter.
9 stars 3 forks source link

Issue with AdobeFlashPlayer.jss #8

Closed Thomgi closed 9 years ago

Thomgi commented 9 years ago

Hi,

Since few days I got an error when running AdobeFlashPlayer.jss in autopkgr/autopkg :

autopkg run AdobeFlashPlayer.jss
Processing AdobeFlashPlayer.jss...
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1469, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1463, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1287, 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 767, in main
    self.groups = self.handle_groups()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 380, in handle_groups
    computer_group = self._add_or_update_smart_group(group)
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 421, in _add_or_update_smart_group
    update_env="jss_group_updated", added_env="jss_group_added")
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 475, in _update_or_create_new
    self.j.put(url, recipe_object)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 234, in put
    self._error_handler(JSSPutError, response)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 179, in _error_handler
    raise exception
jss.exceptions.JSSPutError: Response Code: 500  Response: Internal Server Error. The server encountered an unexpected condition which prevented it from fulfilling the request

Can you help on this issue ? Thanks in advance

sheagcraig commented 9 years ago

Hello!

The Response 500 at the bottom usually means something went wrong at the JSS level, not at the client level. I haven't seen it that often because for the most part the JSS never errors out.

Thomgi commented 9 years ago

Thanks for your answer.

More detail maybe on what happened :

sheagcraig commented 9 years ago

The failure above is from when the group(s) are being created. What smart group or static group names are you specifying in the recipe? Have you overridden the ones in the recipe at all?

Thomgi commented 9 years ago

The smart group should be "AdobeFlashPlayerUpdate-smart", but there was an error on it in JSS log.

So, I just delete it, and let the magic recreate it. Tadaaaa ! It's woring perfect now. Many thanks to your help.

sheagcraig commented 9 years ago

Just for future reference (and for anyone else who might come across this), one possible cause for issues regarding smart groups is that they're named one thing in the JSSImporter arguments, and another thing in the SmartGroupTemplate. However, this usually gives an errro 409 "Conflict".

Thomgi commented 9 years ago

Unfortunately, my problem is coming back. After deleting smart group, autopkg runs well once. But got the same error from the second run and each time it runs.

sheagcraig commented 9 years ago

AdobeFlashPlayer uses an extension attribute. Does your api user have the ability to create extension attributes? Have you changed the smart group template at all?

Barring that, we could look at the actual templates and recipes, especially if you've edited or overridden anything. Also, a sanitized autopkg -vvvv output log would help.

Thomgi commented 9 years ago

API user for autopkgr have create/read/update rights to extension attributes.

There was a change on the smart group template, but it already works with this (I made that change from the beginning of using it :

<computer_group>
    <name>%group_name%</name>
    <is_smart>true</is_smart>
    <criteria>
        <criterion>
            <name>AdobeFlashVersion</name>
            <priority>0</priority>
            <and_or>and</and_or>
            <search_type>is not</search_type>
            <value>%VERSION%</value>
        </criterion>
    </criteria>
</computer_group>

Here it is the autopkg log :

Processing AdobeFlashPlayer.jss...
{u'API_PASSWORD': u'xxxxx',
 u'API_USERNAME': u'autopkgr',
 'AUTOPKG_VERSION': u'0.4.2',
 u'CATEGORY': u'Plugins Internet',
 u'GIT_PATH': u'/usr/local/git/bin/git',
 u'GROUP_NAME': u'AdobeFlashPlayerUpdate-smart',
 u'GROUP_TEMPLATE': u'/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashSmartGroupTemplate.xml',
 u'ICON': u'/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashPlayer.png',
 u'JSS_REPOS': [{
    URL = "afp://xxxxx";
    name = xxxxx;
    password = "xxxxx";
    port = 548;
    "share_name" = CasperRoot;
    type = AFP;
    username = casperrw;
}],
 u'JSS_SUPPRESS_WARNINGS': u'true',
 u'JSS_URL': u'https://xxxxx:8443',
 u'JSS_VERIFY_SSL': False,
 u'NAME': u'AdobeFlashPlayer',
 'PARENT_RECIPES': [u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.sheagcraig.jss-recipes/AdobeFlashPlayer.jss.recipe',
                    u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/AdobeFlashPlayer/AdobeFlashPlayer.pkg.recipe',
                    u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/AdobeFlashPlayer/AdobeFlashPlayer.download.recipe'],
 u'POLICY_CATEGORY': u'Plugins Internet',
 u'POLICY_TEMPLATE': u'/Users/admin/Library/AutoPkg/RecipeOverrides/PolicyTemplate.xml',
 'RECIPE_CACHE_DIR': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer',
 'RECIPE_DIR': '/Users/admin/Library/AutoPkg/RecipeOverrides',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashPlayer.jss.recipe',
 u'RECIPE_REPOS': {u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.gregneagle-recipes': {
    URL = "https://github.com/autopkg/gregneagle-recipes.git";
},
                   u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.keeleysam-recipes': {
    URL = "https://github.com/autopkg/keeleysam-recipes.git";
},
                   u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {
    URL = "https://github.com/autopkg/recipes.git";
},
                   u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {
    URL = "https://github.com/autopkg/rtrouton-recipes.git";
},
                   u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.scriptingosx-recipes': {
    URL = "https://github.com/autopkg/scriptingosx-recipes.git";
},
                   u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.sheagcraig.jss-recipes': {
    URL = "https://github.com/sheagcraig/jss-recipes.git";
}},
 u'RECIPE_SEARCH_DIRS': [u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.gregneagle-recipes',
                         u'.',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.keeleysam-recipes',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.sheagcraig.jss-recipes',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.scriptingosx-recipes',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                         '/Users/admin/Library/AutoPkg/RecipeOverrides',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.sheagcraig.jss-recipes',
                         u'/Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/AdobeFlashPlayer'],
 'verbose': 4}
AdobeFlashURLProvider
{'Input': {}}
AdobeFlashURLProvider: Found URL http://fpdownload.macromedia.com/get/flashplayer/pdc/17.0.0.188/install_flash_player_osx.dmg
{'Output': {'url': 'http://fpdownload.macromedia.com/get/flashplayer/pdc/17.0.0.188/install_flash_player_osx.dmg'}}
URLDownloader
{'Input': {'filename': u'AdobeFlashPlayer.dmg',
           'url': 'http://fpdownload.macromedia.com/get/flashplayer/pdc/17.0.0.188/install_flash_player_osx.dmg'}}
URLDownloader: Item at URL is unchanged.
URLDownloader: Using existing /Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg
{'Output': {'pathname': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg'}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'expected_authority_names': (
    "Developer ID Installer: Adobe Systems, Inc.",
    "Developer ID Certification Authority",
    "Apple Root CA"
),
           'input_path': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg'}}
CodeSignatureVerifier: Mounted disk image /Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg
CodeSignatureVerifier: Verifying installer package signature...
CodeSignatureVerifier: Package "Adobe Flash Player.pkg":
CodeSignatureVerifier:    Status: signed by a certificate trusted by Mac OS X
CodeSignatureVerifier:    Certificate Chain:
CodeSignatureVerifier:     1. Developer ID Installer: Adobe Systems, Inc.
CodeSignatureVerifier:        SHA1 fingerprint: 9D 75 C9 20 01 4A 65 04 94 A7 63 95 E3 91 93 47 04 E8 57 DF
CodeSignatureVerifier:        -----------------------------------------------------------------------------
CodeSignatureVerifier:     2. Developer ID Certification Authority
CodeSignatureVerifier:        SHA1 fingerprint: 3B 16 6C 3B 7D C4 B7 51 C9 FE 2A FA B9 13 56 41 E3 88 E1 86
CodeSignatureVerifier:        -----------------------------------------------------------------------------
CodeSignatureVerifier:     3. Apple Root CA
CodeSignatureVerifier:        SHA1 fingerprint: 61 1E 5B 66 2C 59 3A 08 FF 58 D1 4A E2 24 52 D1 98 DF 6C 60
CodeSignatureVerifier: 
CodeSignatureVerifier: Signature is valid
CodeSignatureVerifier: Authority name chain is valid
{'Output': {}}
Versioner
{'Input': {'input_plist_path': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg/Install Adobe Flash Player.app/Contents/Info.plist',
           'plist_version_key': u'CFBundleVersion'}}
Versioner: Mounted disk image /Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg
Versioner: Found version 17.0.0.188 in file /private/tmp/dmg.9eVVXz/Install Adobe Flash Player.app/Contents/Info.plist
{'Output': {'version': u'17.0.0.188'}}
PkgCopier
{'Input': {'pkg_path': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/AdobeFlashPlayer-17.0.0.188.pkg',
           'source_pkg': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg'}}
PkgCopier: Mounted disk image /Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/downloads/AdobeFlashPlayer.dmg
PkgCopier: Copied /private/tmp/dmg.S9620j/Install Adobe Flash Player.app/Contents/Resources/Adobe Flash Player.pkg to /Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/AdobeFlashPlayer-17.0.0.188.pkg
{'Output': {'pkg_path': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/AdobeFlashPlayer-17.0.0.188.pkg'}}
JSSImporter
{'Input': {'API_PASSWORD': u'xxxxx',
           'API_USERNAME': u'xxxxx',
           'JSS_REPOS': [{
    URL = "afp://xxxxx";
    name = xxxxx;
    password = "xxxxx";
    port = 548;
    "share_name" = CasperRoot;
    type = AFP;
    username = casperrw;
}],
           'JSS_SUPPRESS_WARNINGS': u'true',
           'JSS_URL': u'https://xxxxx:8443',
           'JSS_VERIFY_SSL': False,
           'category': u'Plugins Internet',
           'extension_attributes': (
        {
        "ext_attribute_path" = "/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashPlayerExtensionAttribute.xml";
        name = AdobeFlashVersion;
    }
),
           'groups': (
        {
        name = "AdobeFlashPlayerUpdate-smart";
        smart = 1;
        "template_path" = "/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashSmartGroupTemplate.xml";
    }
),
           'pkg_path': u'/Users/admin/Library/AutoPkg/Cache/local.jss.AdobeFlashPlayer/AdobeFlashPlayer-17.0.0.188.pkg',
           'policy_category': u'Plugins Internet',
           'policy_template': u'/Users/admin/Library/AutoPkg/RecipeOverrides/PolicyTemplate.xml',
           'prod_name': u'AdobeFlashPlayer',
           'self_service_icon': u'/Users/admin/Library/AutoPkg/RecipeOverrides/AdobeFlashPlayer.png',
           'version': u'17.0.0.188'}}
JSSImporter: No value supplied for self_service_description, setting default value of: 
JSSImporter: No value supplied for JSS_MIGRATED, setting default value of: False
JSSImporter: Category type: category-'Plugins Internet' already exists according to JSS, moving on...
JSSImporter: Category type: policy_category-'Plugins Internet' already exists according to JSS, moving on...
JSSImporter: Pkg-object already exists according to JSS, moving on...
JSSImporter: Package upload not needed.
JSSImporter: ComputerExtensionAttribute: AdobeFlashVersion updated.
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1469, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1463, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1287, 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 767, in main
    self.groups = self.handle_groups()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 380, in handle_groups
    computer_group = self._add_or_update_smart_group(group)
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 421, in _add_or_update_smart_group
    update_env="jss_group_updated", added_env="jss_group_added")
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 475, in _update_or_create_new
    self.j.put(url, recipe_object)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 234, in put
    self._error_handler(JSSPutError, response)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 179, in _error_handler
    raise exception
jss.exceptions.JSSPutError: Response Code: 500  Response: Internal Server Error. The server encountered an unexpected condition which prevented it from fulfilling the request
sheagcraig commented 9 years ago

Hmm. What's confusing to me is the 500 response. That's "supposed" to indicate that something went wrong with the server and is unrelated to your PUT. But you can reliably produce it.

I know this sounds really silly, but just to double check-does your API user have Update privileges on Computer Groups?

The recipe is failing specifically where it is attempting to update the smart group. Of course, if it were a permissions issue, I would expect the error to be 401.

Looking at the template, it seems like it is fine. I would imagine a 409 if there were some kind of naming issue.

If you'd like to provide all of the involved files I can see if I can reproduce the problem on my testing server. I imagine you could gist them all.

Also, I would see if the JSS has any logs that may explain why it's throwing the 500 when it gets the put request. Obviously it's happily letting you PUT all of your other smart groups without freaking out.

Thomgi commented 9 years ago

Firstly, thank you for your help. There is not too much time I'm working on JSS. Coming from FileWave then Munki experience, I'm working on JSS since only one month.

Here is everything I can give you.

AdobeFlashPlayer.jss.recipe

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Identifier</key>
    <string>local.jss.AdobeFlashPlayer</string>
    <key>Input</key>
    <dict>
        <key>CATEGORY</key>
        <string>Plugins Internet</string>
        <key>GROUP_NAME</key>
        <string>AdobeFlashPlayerUpdate-smart</string>
        <key>GROUP_TEMPLATE</key>
        <string>%RECIPE_DIR%/AdobeFlashSmartGroupTemplate.xml</string>
        <key>ICON</key>
        <string>%RECIPE_DIR%/AdobeFlashPlayer.png</string>
        <key>NAME</key>
        <string>AdobeFlashPlayer</string>
        <key>POLICY_CATEGORY</key>
        <string>Plugins Internet</string>
        <key>POLICY_TEMPLATE</key>
        <string>%RECIPE_DIR%/PolicyTemplate.xml</string>
        <key>JSS_SUPPRESS_WARNINGS</key>
        <string>true</string>
    </dict>
    <key>ParentRecipe</key>
    <string>com.github.autopkg.jss.FlashPlayerExtractPackage</string>
</dict>
</plist>

AdobeFlashSmartGroupTemplate.xml

<computer_group>
    <name>%group_name%</name>
    <is_smart>true</is_smart>
    <criteria>
        <criterion>
            <name>AdobeFlashVersion</name>
            <priority>0</priority>
            <and_or>and</and_or>
            <search_type>is not</search_type>
            <value>%VERSION%</value>
        </criterion>
    </criteria>
</computer_group>

PolicyTemplate.xml

<policy>
    <general>
        <name>MAJ %PROD_NAME%</name>
        <enabled>true</enabled>
        <frequency>Ongoing</frequency>
        <category>
            <name>%POLICY_CATEGORY%</name>
        </category>
        <trigger_login>true</trigger_login>
        <trigger_other>autoupdate-%PROD_NAME%</trigger_other>
    </general>
    <scope>
        <!--Scope added by JSSImporter-->
    </scope>
    <package_configuration>
        <!--Package added by JSSImporter-->
    </package_configuration>
    <scripts>
        <!--Scripts added by JSSImporter-->
    </scripts>
    <self_service>
        <use_for_self_service>true</use_for_self_service>
        <install_button_text>Install %VERSION%</install_button_text>
        <self_service_description>%SELF_SERVICE_DESCRIPTION%</self_service_description>
    </self_service>
    <maintenance>
        <recon>true</recon>
    </maintenance>
</policy>

AdobeFlashPlayerExtensionAttribute.xml is the default one

<computer_extension_attribute>
    <name>AdobeFlashVersion</name>
    <description />
    <data_type>String</data_type>
    <input_type>
        <type>script</type>
        <platform>Mac</platform>
        <script>#!/bin/bash

FlashVersion=$(defaults read /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/Info.plist CFBundleShortVersionString)

echo "&lt;result&gt;$FlashVersion&lt;/result&gt;"

exit 0</script>
    </input_type>
    <inventory_display>Extension Attributes</inventory_display>
    <recon_display>Extension Attributes</recon_display>
</computer_extension_attribute>

Now, here is what privileges API user have. Read/Write/Update on :

Thomgi commented 9 years ago

Another thing I notice, if I look in the JSS web interface on the history of both flash smart group and another (like firefox) smart group, I can see :

Flash smart group : there is only one entry for the smart group creation capture d ecran 2015-05-19 a 17 12 44

Firefox : there is an "edited" entry each time autopkgr is running + the original smart group creation capture d ecran 2015-05-19 a 17 12 23

sheagcraig commented 9 years ago

@Thomgi Everything looks exactly right-and I'm sure that's not a surprise since you're using all of the other recipes without a problem.

There's nothing wrong with the SmartGroupTemplate or the any conflicts with the names as overridden.

One thing that I would point out that doesn't really matter for this problem, but that you may want to do, is that in your overrides you can delete all of the keys and values for things that you aren't overriding. This way if the parent recipe ever changes it doesn't implicitly override the values. The override should probably only contain things which you want to override.

So the next thing is to try to update that smart group with curl. You'll want to make a copy of the template file and hand edit the %group_name% and %version% replacement variables to something, and then use that edited file in the command below:

F=$(cat /<PATH_TO_YOUR_TEMPLATE_FILE>/AdobeFlashSmartGroupTemplate.xml); curl https://yourjss.org:8443/JSSResource/computergroups/name/AdobeFlashPlayerUpdate-smart --user "<username>:<password>" -H "Content-Type: text/xml" -X PUT -d "$F" --write-out \\n%{http_code}\\n --output -

FWIW, I tried this on both my production and testing servers with your supplied XML and it worked fine.

One thing you could try is to run the curl above and then look on your JSS at the JSS log (on ours it's at /usr/local/jss/logs/JAMFSoftwareServer.log) and see if the error is explained any further. I found some smart group errors in the log that specified the exact error in the criteria, so maybe you can find something useful. If it doesn't clear it up for you, please paste the relevant entries here and I'll take a look.

I would try the curl above in preparation for filing a support request with JAMF. They'll want you to do a curl rather than use unknown software like python-jss/JSSImporter. As I can't recreate the problem, I don't think I could submit one for you. In my experience, they'll definitely give you the runaround if you even mention AutoPkg(r) / Python / etc, so it's better to play it cool and just give them the curl that you tried. And that's basically the stripped down actual thing that JSSImporter is doing! Good luck, and let me know what you learn!

Thomgi commented 9 years ago

After several search, we found that we got an issue with certs/name of our JSS.

After fixing the name, we won't have issue anymore. Many thanks again for your help.

sheagcraig commented 9 years ago

That's great! Thanks for updating me, and I'm glad that it works.