Download Java with Ansible


Ansible is useful for automating server construction, but there are some tough points when trying to install the JDK. There was not much information in Japanese about how to solve it, so I will briefly summarize it.

I can't agree to the license

As you can see from the download screen, you need to agree to the license to download the JDK.

スクリーンショット 2017-10-09 13.58.09.png

In Ansible, you can easily download middleware using the yum module and the get_url module, but in the case of the JDK, you cannot download it obediently. You can work around this issue by giving the cookie that it has been activated.

Cookies can be set in the headers option of the get_url module.

headers: "Cookie:'; oraclelicense=accept-securebackup-cookie'"

Get stuck in certificate check

In addition, Java downloads are done over SSL, so you have to get past certificate issues.

The get_url module has an option called validate_certs, which can be avoided by setting no here (it's an option that literally skips authentication, so use it only for trusted sites. ).

validate_certs: no


You can download Java with the following script.

- name: download JDK
    url: ""
    dest: "/opt/jdk-8u144-linux-x64.rpm"
    headers: "Cookie:'; oraclelicense=accept-securebackup-cookie'"
    validate_certs: no
    owner: root
    group: root
    mode: 744
- name: install JDK from a local file
    name: "/opt/jdk-8u144-linux-x64.rpm"
    state: present

Recommended Posts

Download Java with Ansible
Install Java with Ansible
Comfortable download with JAVA
Install Java and Tomcat with Ansible
Install java with Homebrew
Change seats with java
Switch java with direnv
Let's scrape with Java! !!
Build Java with Wercker
Download with Spring Boot
Endian conversion with JAVA
[Tutorial] Download Eclipse → Run the application with Java (Pleiades)
[Tutorial] Download Eclipse → Run Web application with Java (Pleiades)
Java multi-project creation with Gradle
Getting Started with Java Collection
Basic Authentication with Java 11 HttpClient
Let's experiment with Java inlining
Run batch with docker-compose with Java batch
[Template] MySQL connection with Java
Rewrite Java try-catch with Optional
Install Java 7 with Homebrew (cask)
[Java] JSON communication with jackson
Java to play with Function
Try DB connection with Java
Install Oracle JDK 8 with Ansible
Enable Java EE with NetBeans 9
[Java] JavaConfig with Static InnerClass
Try gRPC with Java, Maven
Let's operate Excel with Java! !!
Version control Java with SDKMAN
RSA encryption / decryption with java 8
Paging PDF with Java + PDFBox.jar
Sort strings functionally with java
Object-oriented (java) with Strike Gundam
[Java] Content acquisition with HttpCliient
Troubleshooting with Java Flight Recorder
Streamline Java testing with Spock
Connect to DB with Java
Error when playing with java
Using Mapper with Java (Spring)
Java study memo 2 with Progate
Getting Started with Java Basics
Seasonal display with Java switch
Use SpatiaLite with Java / JDBC
Study Java with Progate Note 1
Compare Java 8 Optional with Swift
HTML parsing with JAVA (scraping)
Run Java VM with WebAssembly
Screen transition with swing, java
Java unit tests with Mockito
[Java 8] Duplicate deletion (& duplicate check) with Stream
Create an immutable class with JAVA
[Java, Scala] Image resizing with ImageIO
Build a Java project with Gradle
Java to learn with ramen [Part 1]
Morphological analysis in Java with Kuromoji
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
[Java EE] Implement Client with WebSocket
[Java] Branch enum with switch statement
Code Java from Emacs with Eclim