Nov 3, 2021

Deploy and execute a shell script in target hosts using Ansible

Let's imagine you have a script to execute in all target hosts. In this case, let's call it setup.sh and for now, it will just be a Shell/ BASH script.

Step#1 : Create the Setup Script

Lets create the script on our Ansible server because it needs to be local

e.g., create in central/ ansible server

# vi setup.sh

touch test.txt

Step#2: create your play book

# cat play_setup.yml

---

#deploy shell script

- name: Transfer and execute a script.

  hosts: all

  remote_user: oracle

  tasks:

   - name: Transfer the script

     copy: src=setup.sh dest=/home/oracle mode=0777

   - name: Execute the script

     command: sh /home/oracle/setup.sh

Step#3: Now execute your play book after syntax check

# ansible-playbook play_setup.yml --syntax-check

playbook: play_setup.yml


# ansible-playbook play_setup.yml

PLAY [Transfer and execute a script.] ***********************************************************************************

TASK [Gathering Facts] ***********************************************************************************

ok: [192.168.100.1]

ok: [192.168.100.2]

TASK [Transfer the script] ***********************************************************************************

ok: [192.168.100.1]

ok: [192.168.100.2]

TASK [Execute the script] ***********************************************************************************

changed: [192.168.100.1]

changed: [192.168.100.2]

PLAY RECAP ***********************************************************************************

192.168.100.2             : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

192.168.100.1             : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0



Step#4: Verify in one of the target host

connect to 192.168.100.1 and check


$ ls setup.sh

setup.sh

$ ls test.txt

test.txt


We saw here our script deployed and executed successfully.


20 comments:

  1. All thanks to Mr Anderson for helping with my profits and making my fifth withdrawal possible. I'm here to share an amazing life changing opportunity with you. its called Bitcoin / Forex trading options. it is a highly lucrative business which can earn you as much as $2,570 in a week from an initial investment of just $200. I am living proof of this great business opportunity. If anyone is interested in trading on bitcoin or any cryptocurrency and want a successful trade without losing notify Mr Anderson now.Whatsapp: (+447883246472 )
    Email: tdameritrade077@gmail.com

    ReplyDelete
  2. I lost my job few months back and there was no way to get income for my family, things was so tough and I couldn't get anything for my children, not until a met a recommendation on a page writing how Mr Bernie Wilfred helped a lady in getting a huge amount of profit every 6 working days on trading with his management on the cryptocurrency Market, to be honest I never believe it but I took the risk to take a loan of $1000. and I contacted him unbelievable and I was so happy I earn $12,500 in 6 working days, the most joy is that I can now take care of my family I don't know how to appreciate your good work Mr. Bernie Doran God will continue to bless you for being a life saver I have no way to appreciate you than to tell people about your good services.
For a perfect investment and good strategies contact Mr Bernie Doran via WhatsApp :+1(424)285-0682 or Telegram : @Bernie_doran_fx or Email : Bernie.doranfx01@gmail.com

    ReplyDelete
  3. LEGIT FULLZ & TOOLS STORE

    Hello to All !

    We are offering all types of tools & Fullz on discounted price.
    If you are in search of anything regarding fullz, tools, tutorials, Hack Pack, etc
    Feel Free to contact

    ***CONTACT 24/7***
    **Telegram > @leadsupplier
    **ICQ > 752822040
    **Skype > Peeterhacks
    **Wicker me > peeterhacks

    "SSN LEADS/FULLZ AVAILABLE"
    "TOOLS & TUTORIALS AVAILABLE FOR HACKING, SPAMMING,
    CARDING, CASHOUT, CLONING, SCRIPTING ETC"

    **************************************
    "Fresh Spammed SSN Fullz info included"
    >>SSN FULLZ with complete info
    >>CC With CVV (vbv & non vbv) Fullz USA
    >>FULLZ FOR SBA, PUA & TAX RETURN FILLING
    >>USA I.D Photos Front & Back
    >>High Credit Score fullz (700+ Scores)
    >>DL number, Employee Details, Bank Details Included
    >>Complete Premium Info with Relative Info

    ***************************************
    COMPLETE GUIDE FOR TUTORIALS & TOOLS

    "SPAMMING" "HACKING" "CARDING" "CASH OUT"
    "KALI LINUX" "BLOCKCHAIN BLUE PRINTS" "SCRIPTING"
    "FRAUD BIBLE"

    "TOOLS & TUTORIALS LIST"
    =>Ethical Hacking Ebooks, Tools & Tutorials
    =>Bitcoin Hacking
    =>Kali Linux
    =>Fraud Bible
    =>RAT
    =>Keylogger & Keystroke Logger
    =>Whatsapp Hacking & Hacked Version of Whatsapp
    =>Facebook & Google Hacking
    =>Bitcoin Flasher
    =>SQL Injector
    =>Premium Logs (PayPal/Amazon/Coinbase/Netflix/FedEx/Banks)
    =>Bitcoin Cracker
    =>SMTP Linux Root
    =>Shell Scripting
    =>DUMPS with pins track 1 and 2 with & without pin
    =>SMTP's, Safe Socks, Rdp's brute
    =>PHP mailer
    =>SMS Sender & Email Blaster
    =>Cpanel
    =>Server I.P's & Proxies
    =>Viruses & VPN's
    =>HQ Email Combo (Gmail, Yahoo, Hotmail, MSN, AOL, etc.)

    *Serious buyers will always welcome
    *Price will be reduce in bulk order
    *Discount offers will give to serious buyers
    *Hope we do a great business together

    ===>Contact 24/7<===
    ==>Telegram > @leadsupplier
    ==>ICQ > 752822040
    ==>Skype > Peeterhacks
    ==>Wicker me > peeterhacks

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Sir/Madam

    We are authorized Financial consulting firm that work directly with
    some banks in UK.[Natwest Bank, Lloyds Bank.]

    We are providing BG, SBLC, LC, LOAN and lots more for client all over the world.

    Equally,we are ready to work with Brokers and financial
    consultants/consulting firms in their respective countries.

    We are equally ready to pay commission to those Brokers and financial
    consultants/consulting firms.

    Awaiting for your response.

    Best regards,

    Email: financeaperiolimited936@gmail.com

    Skype ID: financeaperiolimited936@outlook.com

    Whatsapp : +447415695557

    Best regards,

    FRED ARNAZ

    ReplyDelete
  6. How to move forward after heartache. I want to share my story with you. I have gone through a lot of pain and suffering because of someone who lied to me. This is why it's so important to be careful about trusting people. Over $20 million was stolen from my Coinbase account in Bitcoins and Ethereum but thanks to these guys at Asset recovery firm (claimpayback) Where i got a reputable funds recovery triangulation specialist to help me get back my lost funds. i immediately opened a case with the smart contract developers at claimpayback after i was directed by kravitz hein their smart contract customer support on claimpayback.com platform and they eventually came to my aid."

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete

  10. We offer certified and verifiable bank instrument via Swift Transmission from a genuine
    provider capable of taking up bound transactions
    BANK INSTRUMENT PARTICULARS
    Instruments :Fully Cash Backed, Fresh Cut Bank Guarantee(Standard ICC format)
    Age:One (1) years and One (1) day
    Rate:Leasing 4+2, Purchase:32+2
    Currency:USD/Euro
    Bank:Top A Rated banks
    Amount:As Advised by Beneficiary
    Intermediary Fees: Two percent(2%) of Face Value payable by Beneficiary
    Tranches :Ass per agreed tranches schedule
    Delivery:Swift MT799/MT760
    Payment :Swift MT103(Wire Transfer)
    Contact Name:Blaine Lorcan
    Email:Blainelorcan@gmail.com

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. QUALITY SSN DOB DL HIGH CREDIT SCORES Leads
    CC with CVV Fullz (USA, UK, CANADA)
    Tutorials & E-Books For Ethical Hacking
    Tools For Everything You Need

    I'm On Telegram = @killhacks & I C Q = 752822040

    Tools & Tutorials Stuff available for
    (Spamming, Carding, Ethical Hacking, LINUX, Programming, Scripting, etc. )
    *Offering complete packages
    *Will guide & teach
    *Invalid stuff will be replaced instantly

    Deals in all kind of Tools, Tutorials, E-books, Leads/Fullz/Pros
    Available 24/7
    FASTEST DELIVERY

    Build Your Own Business with proper guide & Legit Tools
    Always glad to serve

    GOOD LUCK
    Here I'm:
    I C Q = 752822040
    Tele-gram = @killhacks

    ReplyDelete
  14. contact Ethicalhackers009@gmail.com or Whatsapp +14106350697 for any hacking help mine is kept as a secret because of personal reasons, just contact them and come back to give testimony.

    ReplyDelete
  15. This comment has been removed by a blog administrator.

    ReplyDelete
  16. This comment has been removed by a blog administrator.

    ReplyDelete
  17. This comment has been removed by a blog administrator.

    ReplyDelete
  18. This comment has been removed by a blog administrator.

    ReplyDelete
  19. This comment has been removed by a blog administrator.

    ReplyDelete
  20. LOOKING FOR A HACKER TO GET BACK FUNDS FROM FAKE INVESTMENT PLATFORMS? CONTACT WEB BAILIFF CONTRACTOR


    Have you ever been a victim of a scam or lost your money to fake hackers online? It’s a distressing experience that can leave you feeling both violated and helpless. I understand this firsthand, as I fell victim to deceitful individuals posing as binary options and bitcoin investors. I lost a substantial sum of $5,000 and 2 BTC from my bitcoin wallet, which was a heavy blow. It wasn’t until it was too late that I realized I had been duped, and the pain of knowing that I had been scammed was compounded by the financial loss. I felt a deep sense of regret and frustration. I had invested my trust and money into what I believed were legitimate opportunities, only to find out they were nothing more than elaborate traps designed to exploit my financial resources. The sense of betrayal was overwhelming, and I felt like I had no way out of this dark situation. That was until a family member came to my rescue with a recommendation that would ultimately lead to the recovery of my lost assets. An in-law of mine, who had heard about my predicament, suggested that I reach out to Web Bailiff Contractor, a trusted recovery service known for its expertise in reclaiming lost assets from online scams. At first, I was skeptical. After all, I had already been deceived once; how could I be sure that this wasn’t just another scheme? However, desperate times call for desperate measures, and I decided to give it a try. Reaching out to Web Bailiff Contractor turned out to be one of the best decisions I could have made. Their team of professionals quickly took charge of the situation, meticulously investigating the fraudulent activities and tracking down the perpetrators. Their approach was methodical and efficient, and they kept me informed throughout the entire process. In less than 72 hours, they had managed to recover my lost bitcoins and ensured that the scammers were brought to justice. The experience with Web Bailiff Contractor was nothing short of remarkable. They demonstrated a high level of expertise and professionalism, proving that there are indeed trustworthy solutions available for those who have been wronged by online fraudsters. Their ability to recover lost assets and hold scammers accountable was not only reassuring but also empowering. If you find yourself in a similar situation—whether you’ve fallen victim to fake hackers, online dating scams, fraudulent binary investors, or any other type of online deception—know that there is hope. Web Bailiff Contractor specializes in handling such cases and can assist you in reclaiming what you’ve lost. Their services are not just about recovering money or assets; they are about restoring a sense of justice and providing relief to those who have been victimized. In this digital age, online scams have become increasingly sophisticated, and the risk of falling prey to them is ever-present. However, it’s important to remember that there are professionals dedicated to helping individuals recover from these malicious acts. Web Bailiff Contractor is a testament to the fact that there is still a way to fight back against cybercrime and restore what was unjustly taken. WhatsApp
    + 1(360)819 8556

    ReplyDelete

Translate >>