【问题标题】:Error installing jdk17 via Ansible get_url通过 Ansible get_url 安装 jdk17 时出错
【发布时间】:2021-11-20 20:16:58
【问题描述】:

我正在尝试通过 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

如果有人给我建议或指导以解决此问题,我将不胜感激。

【问题讨论】:

    标签: ubuntu ansible java-17


    【解决方案1】:

    根据错误消息和您的剧本,您缺少参数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/
    

    module get_url 也没有参数java_home。

    您可以通过以下方式总结您的步骤

    - 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=yes和src包含://,远程机器会先从URL下载文件。”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-16
      • 1970-01-01
      • 2016-08-25
      • 2015-05-16
      • 2014-05-18
      • 2018-06-11
      • 2013-02-26
      • 2014-05-24
      相关资源
      最近更新 更多