从本地工作,但从另一台服务器的包装员要求根权限

有一点上下文,我使用一个可靠的configuration器在AWS上创buildAMI映像。

包装员的有关部分和ansible:

packer.json

"provisioners": [{ "type": "shell", "inline": [ "sleep 15", "sudo apt-get update", "sudo apt-get install -y aptitude python" ] }, { "type": "ansible", "playbook_file": "../provision/ansible-playbook.yml", "groups": ["webworker"], "extra_arguments": [ "--become-method=sudo" ] }] 

tasks.yml

 - name: Install tools become: true apt: name: "{{ item }}" state: latest with_items: - build-essential - git 

在我的本地机器上,一切顺利。

但是作为CI的一部分,使用我们的Jenkins服务器来运行这个打包器脚本,但是在第一个已经成型的任务中失败了,在这种情况下,第一步是通过apt模块安装一些工具:

 amazon-ebs: "W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)", amazon-ebs: "E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)", amazon-ebs: "E: Unable to lock directory /var/lib/apt/lists/", amazon-ebs: "W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)", amazon-ebs: "W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)", amazon-ebs: "E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)", amazon-ebs: "E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?" 

我已经检查了权限,用户,即使有另一个在后台运行的apt有锁:什么也没有。

更有意思的是,如果我用sudo aptitude ... commandreplaceansible,它可以工作,而且之前的任务有一个shell提供程序,它也可以运行apt-get而不会出错。

再次,这个工作从我的机器(和其他两台计算机),而不是从服务器。 我没有一个ansible.cfg在任何机器(甚至没有默认的)。