Install Java and Tomcat with Ansible

environment

script

inventory.ini


[test-servers]
localhost
#List the target hosts

main.yml


---
#Install JDK and TOMCAT
- hosts: test-servers

  tasks:
  - name:Get the JDK installer
    get_url:
      url: http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
      dest: /tmp
      headers: "Cookie:' gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie'"
      validate_certs: no
      checksum: "sha256: 3d1e8cc66f4fd77acef6093329d5dd95bd06e4a03926c52df794f311a0c093f8"

  - name:Install the JDK
    yum:
      name: /tmp/jdk-8u131-linux-x64.rpm
      state: present
    become: yes

  - name:Remove installer
    file:
      state: absent
      path: /tmp/jdk-8u131-linux-x64.rpm

  - name:Creating a TOMCAT user
    user:
      name: tomcat
    become: yes

  - name:Get TOMCAT installer
    get_url:
      url: http://ftp.riken.jp/net/apache/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz
      dest: ~/apache-tomcat-8.5.15.tar.gz
      checksum: "sha1:67650d6deda0c0ba9e8c7db7fe4006c35d6dc7db"
    become: yes
    become_user: tomcat

  - name:Install tomcat
    unarchive:
      src: ~/apache-tomcat-8.5.15.tar.gz
      dest:  ~/
      remote_src: yes
    become: yes
    become_user: tomcat

  - name:Remove installer
    file:
      state: absent
      path: ~/apache-tomcat-8.5.15.tar.gz
    become: yes
    become_user: tomcat

  - name:Open the port used by Tomcat on the firewall
    firewalld:
      port: 8080/tcp
      permanent: yes
      immediate: yes
      state: enabled
    become: yes

Run

terminal


#Execute the following command
ansible-playbook -i inventory.ini main.yml --ask-pass --ask-sudo-pass

#To specify the ssh user, use the following command
ansible-playbook -i inventory.ini main.yml -u <REMOTE-USER> --ask-pass --ask-sudo-pass

Recommended Posts

Install Java and Tomcat with Ansible
Install Java with Ansible
Install java with Homebrew
Download Java with Ansible
Install Java 7 with Homebrew (cask)
Install Oracle JDK 8 with Ansible
Install java with Ubuntu 16.04 based Docker
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
Install Java with zip on Windows
Use JDBC with Java and Scala.
Output PDF and TIFF with Java 8
Install Java 9 on windows 10 and CentOS 7
Encrypt with Java and decrypt with C #
Monitor Java applications with jolokia and hawtio
Link Java and C ++ code with SWIG
Let's try WebSocket with Java and javascript!
[Java] Reading and writing files with OpenCSV
Remove wine3.0 with ubuntu18.04LTS and install wine5.0 (winehq)
Install Java8 with Yum on Amazon Linux
I tried using OpenCV with Java + Tomcat
Download and install Eclipse (Java) (Mac version)
Install Docker and create Java runtime environment
Deploy an image consisting of Tomcat, Java and MySQL using Ansible and Jenkins
Apache and tomcat
Java and JavaScript
XXE and Java
Install java and android-sdk on Mac using homebrew
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Build and test Java + Gradle applications with Wercker
Try to link Ruby and Java with Dapr
JSON with Java and Jackson Part 2 XSS measures
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java, Apache, Tomcat9 on EC2 (Amazon Linux2)
Prepare a scraping environment with Docker and Java
KMS) Envelope encryption with openssl and java decryption
Switch versions with alternatives after yum install java
Encrypt / decrypt with AES256 in PHP and Java
[Java] Convert and import file values with OpenCSV
[Review] Reading and writing files with java (JDK6)
Build Apache and Tomcat environment with Docker. By the way, Maven & Java cooperation
[Java] Align characters even with mixed half-width and full-width characters
Use fast Mapping library MapStruct with Lombok and Java 11
Getters and setters (Java)
Install Java on Mac
Change seats with java
Solving with Ruby and Java AtCoder ABC129 D 2D array
[Java] Thread and Runnable
Summary of ToString behavior with Java and Groovy annotations
Compile with Java 6 and test with Java 11 while running Maven on Java 8
[Java] Install Amazon Corretto 8
Solving with Ruby, Perl and Java AtCoder ABC 128 C
Install OpenJDK8 with RPM
Java true and false
[Java] String comparison and && and ||
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
Comfortable download with JAVA
Install java and maven using brew on new mac
Install and configure Keycloak