ubuntu - 通过 Ansible get_url 安装 jdk17 时出错

标签 ubuntu ansible java-17

我正在尝试通过 Ansible 在 Ubuntu 20 上安装 Java 1.7。
剧本:

- hosts: all
  tasks:
  - name: Get the JDK installer
    become: true
    get_url:
    url: https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
    dest: /usr/lib/jvm/
    java_home: "{{ dest }}/jdk-{{ java_version }}"

  - name: Unarchive Java distribution file.
    unarchive:
    src: /usr/lib/jvm/openjdk-17_linux-x64_bin.tar.gz
    dest: /usr/lib/jvm/
    remote_src: yes
    list_files: yes
它在第一个 - name 上引发错误堵塞。
ERROR! conflicting action statements: get_url, url

The error appears to be in '/home/ubuntu/ansible01/install_jdk17.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
违规行似乎是
  tasks:
  - name: Get the JDK installer
    ^ here
如果有人给我建议或方向来解决这个问题,我将不胜感激。

最佳答案

根据错误消息和您的剧本,您缺少参数 url 的缩进.

- name: Get the JDK installer
  become: true
  get_url:
    url: https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
    dest: /usr/lib/jvm/
也没有参数java_home对于 module get_url .
您可以通过以下方式总结您的步骤
- name: Download and unpack
  unarchive:
    src: "https://{{ URL }}/{{ FILENAME }}-{{ JAVA_VERSION }}_linux-x64_bin.tar.gz"
    dest: /usr/lib/jvm
    remote_src: yes
  tags: download,unpack
来自 module unarchive : "如果 remote_src=yessrc 包含 :// ,远程机器将首先从 URL 下载文件。"

关于ubuntu - 通过 Ansible get_url 安装 jdk17 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69367649/

相关文章:

ubuntu - apt-get 没有在 ansible 中注册变量

ubuntu - Vagrant 中的 Redis(Ubuntu): how to forward redis port?

java - 是否存在通过 jar、manifest... 明确设置 --add-exports、--add-opens 指令的方法,以避免在命令行上传递它们?

java - Spring boot 2.2.8.RELEASE兼容java版本

c++ - OpenCV VideoCapture 根本无法从我的网络摄像头读取

linux - 如何使用 Linux (Ubuntu 13.04) 在 HP 7610 上启用双面打印

linux - Ubuntu 16.04 中的 Eclipse 交叉编译

windows - 从 ubuntu 连接到 SSAS(SQL Server 分析服务)

ansible - 在角色任务中包含变量

java - 17 版在分析时“未找到依赖关系”