You are on the right track. Here are two ways for you to do it.
1)You can build your config file completely at run time. I recommend this if the only thing in your file is entries from BladeLogic, and is not all name equal value pair.
Add all of the files to your BLPackage except the config file. Add properties to your BLPackage that are something as follows:
HOSTNAME = ??TARGET.FQ_HOST??
IP_ADDRESS = ??TARGET.IP_ADDRESS??
OS = ??TARGET.OS??
OS_VERSION = ??TARGET.OS_VERSION??
PACKAGENAME = /foo/bar/configfilename
Just place the external command in the right order of your BLPackage so that the file is created before any commands to install or start your package are executed and you will be fine. If you do need this to be flexible with the packagename, then leave the string blank as stated above, and you can set the value of that property when you open up the corresponding deploy job for this BLPackage.
2) Create a config file in BladeLogic for this. Do this if the config file is always going to be in the same location and is used for a distinct purpose. Create a new config file in the BladeLogic configuration object dictionary that has an name equal value pair grammar and is given a path to where your config file should be. Then, it is easies for the next steps, if you create a dummy config file with the values in the correct directory on a server. In your BLPackage import the dummy config file. You should now be able to browse all the nvp as individual child objects of the config file. Do the same steps of creating the properties as in solution #1. Now browse into your nvp objects and set the values. For example, click on the "hostname" entity in your BLPackage and then click in the value box. Replace the contents of that box with ??HOSTNAME??. Repeat that for the others. The rest is the same as above.
Could you do all of the above without creating the local properties? I think so. But it is better practice to create the local properties as it is easier to see all property references on the "properties" sheet of the BLPackage than to search the external commands or all the individual entries of the BLPackage for bad references, etc.
I hope I was able to help some way.
Is it possible to do this via blcli or jython?
Opened a support case, and create an RFE to add this functionality. Here's hoping for 8.1. I would love to be able to create blpackages automatically, triggered by our build server when new application files get built.