# Reduce the No. of script files with same content

**URL:** <https://forum.ansible.com/t/reduce-the-no-of-script-files-with-same-content/31440>\
**Category:** Ansible Project\
**Created:** [October 9, 2019, 11:11am UTC](https://forum.ansible.com/t/reduce-the-no-of-script-files-with-same-content/31440 "2019-10-09T11:11:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uppara\_venkat](https://avatars.discourse-cdn.com/v4/letter/u/6a8cbe/32.png) [@Uppara\_venkat](https://forum.ansible.com/u/Uppara_venkat)\
**Post date:** [October 9, 2019, 11:11am UTC](https://forum.ansible.com/t/reduce-the-no-of-script-files-with-same-content/31440/1 "2019-10-09T11:11:17Z")

</div>

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](https://forum.ansible.com/uploads/short-url/fDqWas1ygXvn3OSpMfXVfRI7bkX.script) (115 Bytes)  
> [PackageDeploy\_MMiS\_Offering\_0.0.106.script](https://forum.ansible.com/uploads/short-url/t2vSgzPM0pZ9zurzIJHcmLlEUcM.script) (113 Bytes)  
> [PackageDeploy\_MMiS\_Offering\_0.0.105.script](https://forum.ansible.com/uploads/short-url/4azoBTAvHkxWpLxAkU3Hjs9a5Nr.script) (113 Bytes)  
> [PackageDeploy\_hotfix-IIS.script](https://forum.ansible.com/uploads/short-url/to713zNqrvgKeW2nAtgYTpKKgND.script) (101 Bytes)  
> [PackageDeploy\_hotfix-DDMInfra.script](https://forum.ansible.com/uploads/short-url/tWFKwkDxDPqgzlnRMzes7Ot7wti.script) (106 Bytes)  
> [PackageDeploy\_UDI\_Data\_Model\_0.0.104.script](https://forum.ansible.com/uploads/short-url/ji2R1VOGzwp8KjvzCxGTRuETjf7.script) (114 Bytes)  
> [PackageDeploy\_UDI\_Data\_Model\_100.script](https://forum.ansible.com/uploads/short-url/llxUUBnCRePmuXKL0URx5yWkvEP.script) (110 Bytes)  
> [PackageDeploy\_UDI\_Discovery\_Base\_Enrichment\_0.0.104.script](https://forum.ansible.com/uploads/short-url/h1dQtTb6Kv2oigBwGTgqqC7dFNl.script) (129 Bytes)  
> [PackageDeploy\_Database\_0.0.100.script](https://forum.ansible.com/uploads/short-url/67XD71RFUMxXJOvwwUpsCzWjOgj.script) (108 Bytes)  
> [PackageDeploy\_XCDE\_Outbound\_Adapter\_0.0.101.script](https://forum.ansible.com/uploads/short-url/h8aohnl7llZpe4wawLJ3uAAaFEb.script) (121 Bytes)  
> [PackageDeploy\_Discovery\_Base\_0.0.100.script](https://forum.ansible.com/uploads/short-url/dhioUVetmXMHd4MumlPo583ib8D.script) (114 Bytes)

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [October 9, 2019, 11:33am UTC](https://forum.ansible.com/t/reduce-the-no-of-script-files-with-same-content/31440/2 "2019-10-09T11:33:52Z")

</div>

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.
