Passing dynamic parameters to shell script in Ansible playbook

164 views
Skip to first unread message

Amit Kulkarni

unread,
Dec 8, 2019, 6:21:58 PM12/8/19
to Ansible Project
Hello All,

I wanted to pass dynamic parameters to shell script in playbook.

I am using script module to trigger, any pointers on this will be really helpful.

Regards
Amit
Message has been deleted

Dick Visser

unread,
Dec 9, 2019, 5:22:20 AM12/9/19
to ansible...@googlegroups.com
On Mon, 9 Dec 2019 at 04:05, anil gouranna <anil....@gmail.com> wrote:
>
> Hey Amit,
>
> Thank you for reaching out to me. I am also new to the Ansible world. Please check with someone who is more knowledgable.

He actually did by sending it to this list.

Dick Visser

unread,
Dec 9, 2019, 5:23:47 AM12/9/19
to ansible...@googlegroups.com
You can use variable and jinja templating logic in your script task.
If you need more concrete help, provide more details.

Dick
> --
> 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/CAON3ZR0VwNrb46ELvZK6UG_wL56tms7vpN0a4s1Z3497mxckjg%40mail.gmail.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Amit Kulkarni

unread,
Dec 9, 2019, 7:47:08 AM12/9/19
to Ansible Project
Hello Dick,

Thanks for the response.

Any code snippet that you can share that will be of great help.

Actually I am working Microstrategy build automation, where we wanted to trigger the shell script and pass dynamic parameters (e.g. License key etc) and also need to send the email to DL in case of success and failures.

As far I researched, we can use script module to trigger the any shell script and but wondering how can I pass dynamic parameters every time.

Regards
Amit



Dick Visser

unread,
Dec 9, 2019, 9:16:47 AM12/9/19
to ansible...@googlegroups.com
You can use any variables that you use in your playbook to construct
the actual command:

- name: return motd to registered var
command: /opt/scripts/hackme.sh --license {{ license }} --strategy
{{ strategy }}

etc etc
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAON3ZR06ZP5XTKwPz1hc%2BpvoqDumR%2BU4GnJQi%3DwfnukgNH3Fqg%40mail.gmail.com.

Amit Kulkarni

unread,
Dec 9, 2019, 11:15:29 AM12/9/19
to Ansible Project
Thanks.

Let me try to write it and will paste here for your review.

Regards
Amit

Reply all
Reply to author
Forward
0 new messages