Reduce the No. of script files with same content

Hi all,

I have 13 script files in a directory content is same for all the files name will be change as below:
the script file is like this

bean -d UCMDB service=Packaging\ Services
run deployPackages 1 D:/Software/package UDI_Data_Model_0.0.104.zip 1 1

file name is highlighted this will be change in other files.
all files are listed and executing as below;

OTHER_DEPLOY_SCRIPT: [‘PackageDeploy_UDI_Data_Model_0.0.104.script’,‘PackageDeploy_UDI_Discovery_Base_Enrichment_0.0.104.script’,‘PackageDeploy_UDI_Discovery_Administration_100.script’,‘PackageDeploy_UDI_TenantAssociationRules_100.script’,‘PackageDeploy_NormalizationRules_100.script’,‘PackageDeploy_XCDE_Outbound_Adapter_0.0.101.script’,‘PackageDeploy_EMC_ECS-package_0.0.100.script’,‘PackageDeploy_MMiS_Offering_0.0.105.script’,‘PackageDeploy_Database_0.0.100.zip’,‘PackageDeploy_WebService_0.0.101.script’,‘PackageDeploy_hotfix-DDMInfra.script’,‘PackageDeploy_hotfix-QCIM1H126382-v3.script’,‘PackageDeploy_hotfix-IIS.script’]

  • name: Executes jmxterm to Install other package
    win_shell: ‘{{ucmdb_SERVER_JRE_PATH}}java -jar {{config_PATH}}/jmxterm/{{jmxterm_UBER_JAR}} -l localhost:29601 -i {{config_PATH}}/jmxterm/{{ item }}’
    with_items:
  • “{{ OTHER_DEPLOY_SCRIPT }}”

My concern is wanted to make single scrip file and the pass the file name when it will be executing. Simply to reduce the script files.

Please suggest any methods and provide examples as well.

Please find the attached script fiiles for your reference.

Best regards,
Venkat

(attachments)

PackageDeploy_EMC_ECS-package_0.0.100.script (115 Bytes)
PackageDeploy_MMiS_Offering_0.0.106.script (113 Bytes)
PackageDeploy_MMiS_Offering_0.0.105.script (113 Bytes)
PackageDeploy_hotfix-IIS.script (101 Bytes)
PackageDeploy_hotfix-DDMInfra.script (106 Bytes)
PackageDeploy_UDI_Data_Model_0.0.104.script (114 Bytes)
PackageDeploy_UDI_Data_Model_100.script (110 Bytes)
PackageDeploy_UDI_Discovery_Base_Enrichment_0.0.104.script (129 Bytes)
PackageDeploy_Database_0.0.100.script (108 Bytes)
PackageDeploy_XCDE_Outbound_Adapter_0.0.101.script (121 Bytes)
PackageDeploy_Discovery_Base_0.0.100.script (114 Bytes)

Instead of having thirteen different script names in the list, have a list containing the thirteen different filenames. Create a new script “DeployPackage.script” just like the other thirteen, but have the script expect a filename as a parameter. Then modify your loop so that it runs the same script each time, with “item” as a parameter, so that each time through the loop, DeployPackage.script executes with the next filename from the list being passed to it.

vars:
OTHER_DEPLOY_FILENAMES:

  • ‘UDI_Data_Model_0.0.104.zip’
    …etc…

  • ‘hotfix-IIS.script’

  • name: Executes jmxterm to Install other package
    win_shell: ‘{{ucmdb_SERVER_JRE_PATH}}java -jar {{config_PATH}}/jmxterm/{{jmxterm_UBER_JAR}} -l localhost:29601 -i {{config_PATH}}/jmxterm/DeployPackage.script {{ item }}’
    with_items:

  • “{{ OTHER_DEPLOY_FILENAMES }}”

This is of course completely untested and I know nothing about how to pass parameters to your script, but hopefully the above gives you a rough idea.

That “with_items” looks a bit odd, but if it worked for the scripts it will work for the filenames, I guess.

Regards, K.