使用ansible-playbook安装5.4.1版本



我已经使用命令sudo curl -O -k -L -v -X https://services.gradle.org/distributions/gradle-5.4.zip手动安装了gradel-5.4.1

现在我想使用ansible-playbook自动执行此任务。这是我尝试过的,但它不起作用。剧本和错误信息如下。

请帮? ?

剧本:

--- 
- hosts: servers
become: yes
tasks:
- name: create a Directory /opt/gradle
file:
path: ~/opt/gradel
state: directory
mode: 0755
- name: Unarchive a file that needs to be downloaded (added in 2.0)
unarchive:
src: https://services.gradle.org/distributions/gradle-5.4.1-bin.zip
dest: ~/
remote_src: yes

错误信息:

fatal: FAILED! => {"changed": false, "msg": "Failure downloading https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip, Request failed: <urlopen error unknown url type: https\>"}

我不确定你为什么包括一个随机的反斜杠,但正如消息明确指出的那样,https不是一个合法的协议

- name: Unarchive a file that needs to be downloaded (added in 2.0)
unarchive:
src: https://services.gradle.org/distributions/gradle-5.4.1-bin.zip
dest: ~/
remote_src: yes

我也怀疑dest: ~/,因为~/命名法是一个shell结构,而不是一个实际的路径,但有可能使用os.path.expanduser,你会摆脱它。否则,您将需要将其替换为dest: "{{ ansible_env.HOME }}/"

最新更新