Ansible Java 17优先任务无许可
我正在尝试在Ansible中创建一个任务,这使我的Graalvm Java JDK成为默认安装。我做以下操作:
- name: Make GraalVM Java as the selected version
community.general.alternatives:
name: java
path: '{{ graalvm_home }}/bin/java'
不幸的是,我会收到以下权限错误。在community.general.anternatives中,我没有看到运行该命令的任何选项(我正在执行操作的设备在Linux 18上运行)。如何删除此权限错误?
Make GraalVM Java as the selected version] ***
fatal: [default]: FAILED! => {"changed": false, "cmd": "/usr/bin/update-alternatives --install /usr/bin/java java /opt/graalvm/graalvm-22.1.0-java17/bin/java 50", "msg": "update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied", "rc": 2, "stderr": "update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied\n", "stderr_lines": ["update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied"], "stdout": "", "stdout_lines": []}
I am trying to create a task in Ansible which makes my GraalVM Java JDK as the default installation. I do the following:
- name: Make GraalVM Java as the selected version
community.general.alternatives:
name: java
path: '{{ graalvm_home }}/bin/java'
Unfortunately I get the following permission error. In the community.general.alternatives I did not see any option on running the command as sudo (the device I am doing my operations is running on Linux 18). How can I remove this permission error ?
Make GraalVM Java as the selected version] ***
fatal: [default]: FAILED! => {"changed": false, "cmd": "/usr/bin/update-alternatives --install /usr/bin/java java /opt/graalvm/graalvm-22.1.0-java17/bin/java 50", "msg": "update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied", "rc": 2, "stderr": "update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied\n", "stderr_lines": ["update-alternatives:
error: unable to create file '/var/lib/dpkg/alternatives/java.dpkg-tmp': Permission denied"], "stdout": "", "stdout_lines": []}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,Ansible的“ sudo”是“变为:真实”。因此以下应有作用:
Apparently the "sudo" of Ansible is "become : true". So the following should work: