使用下面的ansible命令安装httpd包时,我将得到
"appserver | FAILED! => {
"cache_update_time": 1556452826,
"cache_updated": false,
"changed": false,
"msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'mini-httpd'' failed: E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\n",
"rc": 100,
"stderr": "E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\n",
"stderr_lines": [
"E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)",
"E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?"
],
"stdout": "",
"stdout_lines": []
}不可接受的命令:
ansible all -m apt -a "name=mini-httpd state=present"发布于 2019-04-28 15:46:30
编辑:下面的内容仍然适用于ansible 2.7,尽管-s | --sudo选项已经被宣布为暂时不受欢迎,并且仍然是兼容的。因为ansible 2.8您只能使用-b | --become
ansible all -b -m apt -a "name=mini-httpd state=present"E:无法打开锁文件/var/lib/ dpkg /锁-前端打开(13:权限被拒绝) E:无法获取dpkg前端锁
安装apt软件包需要是目标机器上的根用户。如果您正在目标计算机上连接的当前用户具有sudo功能,请尝试:
ansible all -s -m apt -a "name=mini-httpd state=present"如果其他特权升级选项不能解决您的问题,请参见ansible --help。
发布于 2020-05-22 16:45:25
-s是无效的,如果您想安装包,您需要是root用户。
您将需要选项--become。
因此,对于Ubuntu上的apache2,命令将如下所示
ansible all -m apt -a "name=apache2 state=present" --becomehttps://stackoverflow.com/questions/55891174
复制相似问题