Question

how to create a ansible play book for below CLI prompt running in EC2 instance. i need to execute cli commands in sequence

[2021-08-18 10:55:59 admin@cmoulaniEMS: ~ ]# ssh -p 8122 admin@10.52.23.67 Password authentication Password:

Insight

Insight Command Line Interface Date: Wed Aug 18 10:56:08 IST 2021

find target instances find target instances

    Target                 : TGMS
    Target Version         : ~
    Target Instance        : TGMS
    Target Instance Version: ~

    Target                 : TMS
    Target Version         : ~
    Target Instance        : TMS
    Target Instance Version: ~

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : cmoulanipsxmaster
    Target Instance Version: V14.00.00A019

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : vivekpsxslave
    Target Instance Version: V14.00.00R000

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : stipsxslave
    Target Instance Version: V14.00.00R000

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : stipsxmaster
    Target Instance Version: V14.00.00R000

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : cmoulanipsxslave
    Target Instance Version: V14.00.00A019

    Target                 : PSX
    Target Version         : V14.00.00
    Target Instance        : vivekpsxmaster
    Target Instance Version: V14.00.00R000

Result: Ok

s t i stipsxmaster s t i stipsxmaster

Result: Ok

PSX:V14.00.00R000:stipsxmaster> update STI_Server_Device STI_Server_Device_Id 123 Max_Connection 5 update STI_Server_Device STI_Server_Device_Id 123 Max_Connection 5

Result: Ok PSX:V14.00.00R000:stipsxmaster>

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

It is not very clear what commands exactly you need to run, but you could use the Ansible Shell module to run specific shell commands on your hosts.

Here is an example:

---
  - name: Shell Examples
    hosts: some_servers
    tasks:

    - name: Name of your task
      shell:
         " ls -lrt /var "
      register: lsout
      tags: lsout
      
    - debug: msg="{{displaylist.stdout_lines}}"

You can add more tasks depending on your needs.

Regards, Bobby