0

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

如果有人给我建议或方向来解决这个问题,我将不胜感激。

4

1 回答 1

0

根据错误消息和您的剧本,您缺少参数的缩进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也没有参数java_homeget_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

From moduleunarchive : "如果remote_src=yes并且src包含://,远程机器将首先从 URL 下载文件。 "

于 2021-09-29T06:17:59.587 回答