我试图写一个简单的Ansible剧本,请看下面的片段。使用Ansible 2.4.0.0、Ubuntu 17.04、Python 2.7.13。这是我第一次使用Ansible和Playbooks,所以请不要太苛刻。我做错了什么?
playbook.yml
---
- name: install packages
hosts: dbservers
become: yes
become_method: sudo
become_user: user
tasks:
- name: Update repositories cache and install "python-minimal" package
apt:
name: python-minimal
update_cache: yes
---
[dbservers]
db ansible_host=127.0.0.1 ansible_port=22 ansible_user=user ansible_ssh_pass=pass ansible_become_pass=pass ansible_become_user=user
The full traceback is:
File "/tmp/ansible_yozgsn/ansible_module_apt.py", line 287, in <module>
import apt
fatal: [db]: FAILED! => {
"changed": false,
"cmd": "apt-get update",
"failed": true,
"invocation": {
"module_args": {
"allow_unauthenticated": false,
"autoclean": false,
"autoremove": false,
"cache_valid_time": 0,
"deb": null,
"default_release": null,
"dpkg_options": "force-confdef,force-confold",
"force": false,
"force_apt_get": false,
"install_recommends": null,
"name": "python-minimal",
"only_upgrade": false,
"package": [
"python-minimal"
],
"purge": false,
"state": "present",
"update_cache": true,
"upgrade": null
}
},
"msg": "W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)\nE: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)\nE: Unable to lock directory /var/lib/apt/lists/\nW: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)\nW: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)",
"rc": 100,
"stderr": "W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)\nE: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)\nE: Unable to lock directory /var/lib/apt/lists/\nW: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)\nW: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)\n",
"stderr_lines": [
"W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)",
"E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)",
"E: Unable to lock directory /var/lib/apt/lists/",
"W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)",
"W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)"
],
"stdout": "Reading package lists...\n",
"stdout_lines": [
"Reading package lists..."
]
}
编辑:如果我通过SSH连接到同一台机器,我可以手动更新apt-cache并使用相同的用户(使用sudo)安装包。如果我在Playbook中运行命令'whoami',它将返回预期的结果(用户名)。
如果您的用户具有sudo访问权限,请使用bare:
-
tasks:
- name: Update repositories cache and install "python-minimal" package
become: yes
apt:
name: python-minimal
update_cache: yes
有趣的是,当我尝试它下载的sudo版本时,但是终端中不能识别。 我的节点是10.16。我的净现值是6.9。0 这是文件问题还是我的Mac?
问题内容: 当我尝试安装pyrebase时,出现此错误消息。 PermissionError:[Errno 13]权限被拒绝:/Users/myname/anaconda/lib/python3.6/site- packages/google/api 我能做什么? 问题答案: 使用了Linux或Windows上运行命令提示符管理员
问题内容: 我想编写一个响应S3 put事件的处理程序,以将上载到mp4的任何avi文件转换为。我使用AWS工具包插件在Java中,Eclipse中进行了此操作。对于视频转换,我将ffmpeg与ffmpeg- cli-wrapper一起使用 ,并且在源代码树中提供了ffmpeg的静态(Linux)二进制文件。 我发现上载函数时,二进制文件被放入,但是当我尝试使用编写的测试函数时,出现“权限被拒绝”
我正试图将位图保存到文件中,但android studio抛出了一个异常java。io。FileNotFoundException:/storage/simulated/0/Pictures/savedBitmap。png(权限被拒绝)我做错了什么?
我有一个从Ubuntu软件应用程序安装的IntelliJ IDEA Ultimate 2022.1.2。它被配置为使用Maven包装器。当我在java项目上执行“安装”时(从生命周期菜单),我得到两个错误: git测试: 协议测试: maven-wrapper.properties: 同样的项目在不同的机器上运行良好。不能解决问题。