Reduce the No. of script files with same content

12 views
Skip to first unread message

Uppara venkat

unread,
Oct 9, 2019, 7:11:47 AM10/9/19
to ansible...@googlegroups.com
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 


PackageDeploy_EMC_ECS-package_0.0.100.script
PackageDeploy_XCDE_Outbound_Adapter_0.0.101.script
PackageDeploy_Discovery_Base_0.0.100.script
PackageDeploy_MMiS_Offering_0.0.106.script
PackageDeploy_MMiS_Offering_0.0.105.script
PackageDeploy_hotfix-IIS.script
PackageDeploy_hotfix-DDMInfra.script
PackageDeploy_UDI_Data_Model_0.0.104.script
PackageDeploy_UDI_Data_Model_100.script
PackageDeploy_UDI_Discovery_Base_Enrichment_0.0.104.script
PackageDeploy_Database_0.0.100.script

Karl Auer

unread,
Oct 9, 2019, 7:34:13 AM10/9/19
to ansible-project

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.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFMhZ_KA3tG1xuATq59FQb-oK3g0VJoe-hvCPrMnayQA2nACLA%40mail.gmail.com.


--

Karl Auer { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous:
958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Reply all
Reply to author
Forward
0 new messages