我正在尝试通过 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=yes
和 src
包含 ://
,远程机器将首先从 URL 下载文件。"
关于ubuntu - 通过 Ansible get_url 安装 jdk17 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69367649/