首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Ansible get_url安装jdk17时出错

通过Ansible get_url安装jdk17时出错
EN

Stack Overflow用户
提问于 2021-09-28 19:43:29
回答 1查看 112关注 0票数 0

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

攻略:

代码语言:javascript
复制
- 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块上抛出错误。

代码语言:javascript
复制
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.

令人不快的行看起来是

代码语言:javascript
复制
  tasks:
  - name: Get the JDK installer
    ^ here

如果有人给我解决这个问题的建议或方向,我将非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2021-09-29 06:18:00

根据错误消息和您的攻略,您缺少参数url的缩进。

代码语言:javascript
复制
- 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

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

代码语言:javascript
复制
- 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下载文件。”

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69367649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档