ansible / ubuntu:在AWS实例上添加repos后更新缓存失败

时间:2018-03-09 10:03:04

标签: amazon-web-services ubuntu amazon-ec2 ansible apt

我创建了一些ansible次播放,其中一次添加了安装Dockercertbot所需的回购/密钥。

- name: Add Docker's GPG key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present
  become: true


- name: Add Docker & Certbot repo
  apt_repository:
    repo: "{{ item }}"
    state: present
  become: true
  with_items:
    - "deb [arch=amd64] {{ docker_repo }} {{ ubuntu_release }} stable"
    - "ppa:certbot/certbot"

这是奇怪的部分......

播放将运行的第一次时间,每次播放都会结束;

时间,播放失败,更新缓存错误;

当我登录实例并运行sudo apt update

ubuntu@ip-10-0-1-246:~$ sudo apt update
Hit:1 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial InRelease
0% [1 InRelease gpgv 247 kB] [Waiting for headers] [Connecting to security.ubuntu.com (91.189.91.26)] [Connecting to ppa.launchpad.net]Couldn't create tempfiles for splitting up /var/lib/apt/lists/eu-west-2.eErr:1 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial InRelease                                                                  
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Get:2 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]                                                 
0% [2 InRelease gpgv 102 kB] [Waiting for headers] [Waiting for headers] [Connecting to ppa.launchpad.net]Couldn't create tempfiles for splitting up /var/lib/apt/lists/partial/eu-west-2.ec2.archive.ubuntu.comErr:2 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease                             
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Get:3 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]                  
0% [3 InRelease gpgv 102 kB] [Waiting for headers] [Connecting to ppa.launchpad.net]Couldn't create tempfiles for splitting up /var/lib/apt/lists/partial/eu-west-2.ec2.archive.ubuntu.com_ubuntu_dists_xenial-bErr:3 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease     
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Hit:4 http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease              
Err:4 http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InReleasepfiles for splitting up /var/lib/apt/lists/ppa.launchpad.net_certbot_certbot_ubuntu_dists_xenial_InRelease
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:6 https://download.docker.com/linux/ubuntu xenial InRelease
Err:6 https://download.docker.com/linux/ubuntu xenial InReleaseouldn't create tempfiles for splitting up /var/lib/apt/lists/download.docker.com_linux_ubuntu_dists_xenial_InRelease
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Err:5 http://security.ubuntu.com/ubuntu xenial-security InReleaseng up /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_xenial-security_InRelease
  Could not execute 'apt-key' to verify signature (is gnupg installed?)
Fetched 306 kB in 0s (791 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://eu-west-2.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://download.docker.com/linux/ubuntu xenial InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://security.ubuntu.com/ubuntu xenial-security InRelease: Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch https://download.docker.com/linux/ubuntu/dists/xenial/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Failed to fetch http://ppa.launchpad.net/certbot/certbot/ubuntu/dists/xenial/InRelease  Could not execute 'apt-key' to verify signature (is gnupg installed?)
W: Some index files failed to download. They have been ignored, or old ones used instead

重启后问题解决了(!!!),然后在播放后再次出现同样的问题......

我还安装了gnugpg2但没有任何成功......

1 个答案:

答案 0 :(得分:0)

这是/tmp文件夹权限问题。

出于某种原因(尚未想到),重启后重新启动:

drwxrwxrwt 8 root root 4096 Mar  9 10:59 /tmp

运行apt命令后:

drwxr-xr-x 11 root root 4096 Mar  9 10:44 /tmp

添加为tmp(无双关语)解决问题:

- name: Enforce appropriate /tmp folder permissions
  file:
    path: /tmp
    owner: root
    group: root
    mode: 0777
  become: true
  changed_when: false