我需要使用 ansible 在运行 SUSE Linux 的一台虚拟机上安装 java。
以下是我正在使用的剧本代码:
- name: Download Java
become_user: "{{user}}"
command: "wget -q -O {{java_archive}} --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' {{download_url}} creates={{java_archive}}"
- name: Fix ownership
become_user: "{{user}}"
file: state=directory path={{java_name}} owner={{user}} group={{user}} recurse=yes
- zypper: name={{download_folder}}/jdk-8u5-linux-x64.rpm become_user={{user}} state=present
- name: Clean up
become_user: "{{user}}"
file: state=absent path={{java_archive}}
我面临的问题是安装程序在安装时需要一些交互。我如何自动化它?或者还有其他方法可以实现这一目标?
根据评论中的要求,当我尝试在没有 ansible 的情况下安装时,会出现以下消息。
答案1
从ansible-doc zypper
:
- oldpackage
Adds `--oldpackage' option to `zypper'. Allows to downgrade packages
with less side-effects than force. This is implied as soon as a
version is specified as part of the package name.
(Choices: yes, no)[Default: no]
尝试一下oldpackage=yes
,如果没有帮助,您可以使用更激进的force=yes
选项。