7 Replies Latest reply on Aug 28, 2012 3:28 PM by mazz

    rhq:bundle is not expanding properties

    Ken Rumer Newbie

      My deploy.xml looks like below.  It works fine in when run from rhq-bundle-deployer, but from the GUI it is asking for ${archive-name} file to be uploaded.  Is this a bug?  Am I doing something wrong?

       

      <?xml version="1.0"?>

      <!-- Author ------ -->

      <project

          name="jdk1.6-install"

          default="main"

          xmlns:rhq="antlib:org.rhq.bundle">

       

       

          <property

              name="bundle-name"

              value="jdk1.6" />

          <property

              name="bundle-version"

              value="1.0" />

          <property

              name="product-version"

              value="0_33" />

          <property

              name="OS"

              value="LINUX" />

          <property

              name="processor"

              value="x86_64" />

          <property

              name="product-folder"

              value="${bundle-name}.${product-version}" />

          <property

              name="archive-name"

              value="${bundle-name}.${product-version}-${OS}-${processor}.zip" />

       

       

          <rhq:bundle

              name="${bundle-name}"

              version="${bundle-version}"

              description="Installs ${bundle-name} version=${bundle-version}">

              <rhq:deployment-unit

                  name="${bundle-name}"

                  preinstallTarget="preinstall"

                  postinstallTarget="postinstall"

                  manageRootDir="true">

                  <rhq:archive

                      name="${archive-name}"

                      exploded="true">

                  </rhq:archive>

                  <rhq:file name="preinstall.sh" />

                  <rhq:file name="postinstall.sh" />

              </rhq:deployment-unit>

          </rhq:bundle>

       

       

          <target name="main"/>

       

       

          <target name="preinstall">

              <mkdir dir="${rhq.deploy.dir}" />

              <rhq:audit

                  action="Deployment Properties"

                  info="Properties for ${rhq.deploy.name}"

                  message="See details">ID: ${rhq.deploy.id}

      Directory: ${rhq.deploy.dir}

      hostname=${rhq.system.hostname}

      os.name=${rhq.system.os.name}

      os.version=${rhq.system.os.version}

      os.type=${rhq.system.os.type}

      architecture=${rhq.system.architecture}

      interfaces.java.address=${rhq.system.interfaces.java.address}</rhq:audit>

              <rhq:audit

                  action="${bundle-name} preinstall"

                  info="executing preinstall.sh script" />

              <chmod file="preinstall.sh" perm="700" />

              <exec

                  executable="preinstall.sh"

                  failifexecutionfails="false"

                  failonerror="true"

                  logError="true"

                  resultproperty="result"

                  resolveexecutable="true">

                      <arg value="deploy.name=${rhq.deploy.name}" />

                      <arg value="deploy.id=${rhq.deploy.id}" />

                      <arg value="deploy.dir=${rhq.deploy.dir}" />

                      <arg value="hostname=${rhq.system.hostname}" />

                      <arg value="os.name=${rhq.system.os.name}" />

                      <arg value="os.version=${rhq.system.os.version}" />

                      <arg value="os.type=${rhq.system.os.type}" />

                      <arg value="architecture=${rhq.system.architecture}" />

                      <arg value="interfaces.java.address=${rhq.system.interfaces.java.address}" />

              </exec>

              <rhq:audit

                  status="FAILURE"

                  action="${bundle-name} preinstall"

                  info="preinstall.sh script was not found or script execution failed"

                  message="${output}">${error}</rhq:audit>

              <rhq:audit

                  action="${bundle-name} preinstall"

                  info="preinstall complete, exit code=${result}. Installing to ${rhq.deploy.dir}"

                  message="${output}">${error}</rhq:audit>

          </target>

       

       

          <target name="postinstall">

              <chmod file="postinstall.sh" perm="700" />

              <exec

                  executable="postinstall.sh"

                  failifexecutionfails="false"

                  failonerror="true"

                  logError="true"

                  resultproperty="result"

                  resolveexecutable="true">

                      <arg value="deploy.name=${rhq.deploy.name}" />

                      <arg value="deploy.id=${rhq.deploy.id}" />

                      <arg value="deploy.dir=${rhq.deploy.dir}" />

                      <arg value="hostname=${rhq.system.hostname}" />

                      <arg value="os.name=${rhq.system.os.name}" />

                      <arg value="os.version=${rhq.system.os.version}" />

                      <arg value="os.type=${rhq.system.os.type}" />

                      <arg value="architecture=${rhq.system.architecture}" />

                      <arg value="interfaces.java.address=${rhq.system.interfaces.java.address}" />

              </exec>

              <rhq:audit

                  status="FAILURE"

                  action="${bundle-name} postinstall"

                  info="postinstall.sh script was not found"

                  message="postinstall.sh script was not found. Continuing bundle deployment." />

              <rhq:audit

                  action="${bundle-name} postinstall"

                  info="postinstall complete. Installed at ${rhq.deploy.dir}" />

          </target>

       

       

      </project>

        • 1. Re: rhq:bundle is not expanding properties
          Jirka Kremser Newbie

          The ${variable} syntax can be used only withing the scope of Ant elements. However, you can use https://docs.jboss.org/author/display/RHQ/Provisioning#Provisioning-TemplatizingFiles

          1 of 1 people found this helpful
          • 2. Re: rhq:bundle is not expanding properties
            mazz Master

            Ok, so to better understand what's happening, think about the order of processing that has to happen.

             

            When you upload a bundle, RHQ will take a look at your recipe and determine what bundle files need to exist for that bundle to be properly deployed. This means it scans your <rhq:bundle> element for things like <rhq:archive>. In your case, it sees:

             

            <rhq:archive name="${archive-name}" exploded="true">

             

            Now, you haven't done any configuration or setting of property values yet let alone running the Ant recipe yet. RHQ will see an rhq:archive defined and will look to see if you have the named archive in your bundle - if one doesn't exist, it will ask for it. In this case, it will look for (and find missing) a bundle file named literally ${archive-name}. Again, no configuration has been set up yet, it looks at the name literally.

             

            Once you upload the bundle files required by the receipe, then it creates the bundle. Thereafter, you then DEPLOY that bundle and THEN is when it asks for configuration properties (and it would be here that you would then enter archive-name property value - but obviously its too late and this isn't want you want.

             

            In short, you can't "templatize" the names of your bundle files. You have to explicitly name the bundle files you want associated with that bundle version. I'm not exactly sure why you would want to paramaterize that (since you normally bundle up all the files with the recipe), but regardless of the reasons, you can't do what you want, due to the way the creation and uploading of bundles works in conjunction with when and how you deploy those bundles.

             

            You should hardcode a common name of your archive in the recipe and not parameterize it.

             

            Hopefully, that explanation makes sense.

            • 3. Re: rhq:bundle is not expanding properties
              Ken Rumer Newbie

              Thank you, John.  That makes perfect sense.  The reason for setting these properties is because they are used several times throughout the deploy.xml.  I am attempting to setup a standard for Infrastructure as Code, and my goal was to configure a standard template for bundles.  I have come up with a simple workaround, there is a 'build' step for this and I will templatize deploy.xml and filter on build.

               

              Thanks for your help!

              Ken

              • 4. Re: rhq:bundle is not expanding properties
                Lukas Krejci Apprentice

                As I understood it, Ken didn't try to templatize the bundle or its files. All he wanted to do was to define some stuff using the <property> tags and then later use it in the recipe. His complaint, which I think is valid, is that those properties aren't taken into account in the UI. Notice that he used standard ANT <property> tags, not RHQ's <rhq:input-property> (which I think are the ones we use for configuration?).

                • 5. Re: rhq:bundle is not expanding properties
                  mazz Master

                  Yeah, I notice his usage of <property> that builds up the arhive-name. I think the problem is what I alluded to in my other post - we don't actually run the Ant recipe on the server side. We just parse it. We can't do the property replacements because, IIRC, that requires more than just asking the ANT parser to process the XML , it requires ANT to actually run through the script (which we do not want to do on the server - it only gets run on the agent during bundle deployment). So, again, it is a problem of workflow and how the recipe is processed. Note also that if we do run this receipe on the server, some properties are not guaranteed to be the same as when run on the agent - some may actually get different values from when it really runs on the agent (think of OS specific properties or things like that e.g. java.io.tmpdir or java.version or os.name or whatever).

                   

                  This is just a limitation of our usage of ANT as the recipe implementation. You can't do everything you can do in regular ant - this is one such case where there is a limitation on the usage of properties. We typically tell people to use rhq:input-property since those are set by the user to configure the bundle deployment. If you use normal properties, the limitation is you can't use them to name your archive bundle file names.

                  • 6. Re: rhq:bundle is not expanding properties
                    Ken Rumer Newbie

                    Can the documentation for 'rhq:bundle' be updated?  This was a gotcha for me.  The rhq-bundle-deployer client application does expand these properties, so I it became an issue after testing the bundle.  Kinda sucked...  Thanks, again.

                    • 7. Re: rhq:bundle is not expanding properties
                      mazz Master

                      I put a blurb in the rhq:archive and rhq:file docs that say "NOTE: You cannot use ${} property definitions in the value of this attribute."

                       

                      https://docs.jboss.org/author/display/RHQ/Ant+Bundles#AntBundles-rhq%3Aarchive

                      https://docs.jboss.org/author/display/RHQ/Ant+Bundles#AntBundles-rhq%3Afile