Nov 10, 2021

Ansible automation to install Java in Linux machines

We can install Java in multiple targets / linux hosts using ansible. Here I am showing you one demo scenario to do the following tasks using Ansible:

1. Create directory

2. Unzip/Install Java software 

3. Create a symbolic link to uninstalled Java

 Create the playbook with name something like "java_install.yml".

Step#1: Create the play book

[root@demosys01 ~]#  cat java_install.yml

---

- hosts: all

  remote_user: oracle

  tasks:

   - name: Create Folder

     file:

      path: /u01/fmw/java

      mode: 0755

      state: directory

   - name: Unpack archive

     unarchive:

      src: /software/jdk-8u291-linux-x64.tar.gz

      dest: /u01/fmw/java

      remote_src: yes

   - name: Create symbolic link

     file:

      src: "jdk1.8.0_291"

      dest: "/u01/fmw/java/jdk"

      state: link

[root@demosys01 ~]#


Step#2:  Verify the playbook to check syntax errors:

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

playbook: java_install.yml

#

Here, no errors found. Now go-ahed to run the play book.


Step#3: Run the play book

[root@demosys01 ~]# ansible-playbook java_install.yml

PLAY [all] ***********************************************************************************

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

ok: [192.168.100.1]

ok: [192.168.100.2]


TASK [Create Folder] ***********************************************************************************

changed: [192.168.100.1]

changed: [192.168.100.2]


TASK [Unpack archive] ***************************************************************************************************************************************

changed: [192.168.100.1]

changed: [192.168.100.2]


TASK [Create symbolic link] ***********************************************************************************

changed: [192.168.100.1]

changed: [192.168.100.2]


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

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

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

[root@demosys01 ~]#


Step#4: Now Verify in one of the target host:

verify in target host:


[oracle@example01 ]$ hostname -i

192.168.100.2

[oracle@example01 ]$ cd /u01/fmw/java

[oracle@example01 java]$ ls -l

total 4

lrwxrwxrwx 1 oracle dba   12 Nov 10 09:04 jdk -> jdk1.8.0_291

drwxr-xr-x 8 oracle dba 4096 Jun  2 10:05 jdk1.8.0_291

[oracle@example01 java]$

11 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. This comment has been removed by a blog administrator.

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

    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. This comment has been removed by a blog administrator.

    ReplyDelete
  11. You dont have to panic about the whereabout of your stolen cryptocurrency.These recovery experts I'm about to introduce you to are one of the best when it comes to crypto asset recovery.I introduced two of my friends who were victims of crypto frauds and they were able to help them recover $162,000 worth of bitcoin successfully .All you need to do is to reach out to these experts known as SPYHOST CYBER SERVICES through any of the available means in order to get your stolen assets recovered Kindly contact them via their official E-mail: spyhost@cyberdude.com
    This article is for crypto scam victims,Ignore if you are not affected. Regards

    ReplyDelete

Translate >>