Running shell script using Ansible

43 views
Skip to first unread message

Amit Kulkarni

unread,
Jan 6, 2020, 8:57:29 PM1/6/20
to Ansible Project
Hello All,

I need to execute shell script using ansible but need to pass arguments to this script without using -e arguments.

Is there anyway if we can read the file kept inside the package and read those variables in ansible playbooks and pass it to shell script.

Let me know if there is anyway to achieve this.

Regards
Amit

Dick Visser

unread,
Jan 7, 2020, 3:35:40 AM1/7/20
to ansible...@googlegroups.com
The shell module just executes what you tell it to - including arguments. So no problem there. Read again 

The -e arguments to ansible are a way to provide/override variables. Don’t mix those up. 

You mention things like “reading a file which is kept in a package”. That is something different than running a shell command.

So, could you please tell clearly:


- What you are trying to achieve.

- How you are doing this.

- What problems you encounter.

- Which command did you run, and what output did you get from that (copied as text, not as images/attachments/screenshots)

- What the relevant tasks/playbooks/code/variables look like




--
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/CAON3ZR2HX2DoJunckcUC1OSp1d2px8z-rcQ0%2BNTXQ26dcPqONA%40mail.gmail.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Amit Kulkarni

unread,
Jan 7, 2020, 8:34:54 AM1/7/20
to Ansible Project
Hello Dick,

Thanks for your response.

I am trying to perform installation on I server (Microstrategy component) and binaries along with shell script should be available in bit bucket repository.

Ansible should be able to pull that tar file and unzip it.

After this it should be able to trigger the shell script and for this script it needs some parameters to be passed.

I have seen in documentation that we can pass these parameters in play book it self however that will be hard coding directly in the playbook, hence I was thinking to read it from file and pass it to shell script.

Let me know if you need any further details to this.

Appreciate your inputs on this.

Regards
Amit

Dick Visser

unread,
Jan 7, 2020, 10:16:07 AM1/7/20
to ansible...@googlegroups.com
Hi

It sounds like you are at the very beginning and just exploring options, as you don’t have any ansible code yet.
You might look at the slurp module to fetch remote content, examine that and use it later in the shell command. 


Dick 

Amit Kulkarni

unread,
Jan 7, 2020, 11:37:15 AM1/7/20
to Ansible Project
Hi Dick,

I am at the starting point but I don't want to fetch package from node but have to pull from bit bucket repository which is similar to git.

Regards
Amit



Dick Visser

unread,
Jan 7, 2020, 12:25:59 PM1/7/20
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages