Issue 1:
ISSUE TYPE

Feature Idea

COMPONENT NAME

Module apt_key

ANSIBLE VERSION

ansible 2.2.1.0
config file = ./ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

[defaults]
inventory = local.ini
remote_user = ansible
hash_behaviour = merge

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=90s
control_path = .ssh/%%h-%%p-%%r.master

OS / ENVIRONMENT

Ansible runs from Debian Stretch and is managing Debian Jessie nodes.

SUMMARY

I am reopening #6693 which was closed due to repos migration.

I have encountered the same issue: a apt key gets expired and Ansible won't update it. Due to lack of the update feature apt wasn't possible to update cache and install/upgrade packages.

I need to workaround this feature by running ansible ad-hoc command removing this apt key and then running the playbook again.

STEPS TO REPRODUCE

- name: Fusion directory apt key
apt_key:
id: 62B4981F
keyserver: 'keys.gnupg.net'

EXPECTED RESULTS

When the key expires, download it again to check if new one is available.

ACTUAL RESULTS

Nothing changed, Ansible reports OK.

TASK [ldap : Fusion directory apt key] *************************************
ok: [node-jessie]

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

apt_key_module

ANSIBLE VERSION

ansible 2.3.0.0
config file = /Users/raulcuza/dev/cg/transit/transit/infra/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.13 (default, Dec 18 2016, 07:03:34) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]

CONFIGURATION

[defaults]
ansible_managed = ixntransit ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
inventory = inventories/dev
roles_path = ./roles
retry_files_enabled = False
transport = ssh
vault_password_file = ~/.vault_pass

[ssh_connection]
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=30m
control_path = ~/.ssh/ansible-%%r@%%h:%%p
pipelining = True

OS / ENVIRONMENT

ubuntu 16.04

SUMMARY

When I run a playbook that installs a new key, it is not able to install packages from the repo that is also added. If I manually ssh into the box and run sudo apt-key update sudo apt-get update, I can then run the playbook successfully.

STEPS TO REPRODUCE

Start with a stock Ubuntu 16.04 with only sudo apt-get install -y python python-apt run on it.

Run the below role against it.

---
- name: install esl-erlang apt repo
apt_repository:
filename: erlang-solutions
repo: deb http://binaries.erlang-solutions.com/debian xenial contrib
state: present
update_cache: yes

- name: install esl-erlang apt signing key
apt_key:
url: "https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc"
state: present

- name: install apt packages
apt:
autoremove: yes
cache_valid_time: 300
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- esl-erlang
- elixir

EXPECTED RESULTS

I expect all the packages from the new repo to be installed with authentication verified.

ACTUAL RESULTS

I get an error stating that the packages cannot be installed because they are not verified.

TASK [eucalyptus : install apt packages] *******************************************************************************************************************************************
failed: [10.0.0.12] (item=[u'esl-erlang', u'elixir', u'libssl1.0.0', u'locales', u'postgresql-client']) => {"cache_update_time": 1495847381, "cache_updated": false, "failed": true, "item": ["esl-erlang", "elixir", "libssl1.0.0", "locales", "postgresql-client"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" --auto-remove install 'esl-erlang' 'elixir' 'postgresql-client'' failed: E: There were unauthenticated packages and -y was used without --allow-unauthenticated\n", "stderr": "E: There were unauthenticated packages and -y was used without --allow-unauthenticated\n", "stderr_lines": ["E: There were unauthenticated packages and -y was used without --allow-unauthenticated"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n adwaita-icon-theme at-spi2-core colord colord-data dconf-gsettings-backend\n dconf-service emacsen-common erlang-mode fontconfig fontconfig-config\n fonts-dejavu-core glib-networking glib-networking-common\n glib-networking-services gsettings-desktop-schemas hicolor-icon-theme\n humanity-icon-theme libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data\n libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3\n libboost-filesystem1.58.0 libboost-system1.58.0 libcairo-gobject2 libcairo2\n libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1\n libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa\n libepoxy0 libexif12 libfontconfig1 libgbm1 libgd3 libgdk-pixbuf2.0-0\n libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa\n libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0\n libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common\n libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libjbig0\n libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common\n liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3\n libnotify4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0\n libpciaccess0 libpixman-1-0 libpq5 libprotobuf-lite9v5 libproxy1v5\n librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsctp1\n libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtiff5\n libtxc-dxtn-s2tc0 libvpx3 libwayland-client0 libwayland-cursor0\n libwayland-egl1-mesa libwayland-server0 libwxbase3.0-0v5 libwxgtk3.0-0v5\n libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0\n libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1\n libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxpm4\n libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1\n notification-daemon postgresql-client-9.5 postgresql-client-common\n ubuntu-mono x11-common\nSuggested packages:\n colord-sensor-argyll erlang erlang-manpages erlang-doc default-jre-headless\n | java2-runtime-headless | java1-runtime-headless | java2-runtime\n | java1-runtime cups-common libgd-tools gphoto2 gvfs liblcms2-utils\n librsvg2-bin avahi-daemon hplip libsane-extras sane-utils lksctp-tools\n postgresql-9.5 postgresql-doc-9.5\nThe following NEW packages will be installed:\n adwaita-icon-theme at-spi2-core colord colord-data dconf-gsettings-backend\n dconf-service elixir emacsen-common erlang-mode esl-erlang fontconfig\n fontconfig-config fonts-dejavu-core glib-networking glib-networking-common\n glib-networking-services gsettings-desktop-schemas hicolor-icon-theme\n humanity-icon-theme libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data\n libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3\n libboost-filesystem1.58.0 libboost-system1.58.0 libcairo-gobject2 libcairo2\n libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1\n libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa\n libepoxy0 libexif12 libfontconfig1 libgbm1 libgd3 libgdk-pixbuf2.0-0\n libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa\n libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0\n libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common\n libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libjbig0\n libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common\n liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3\n libnotify4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0\n libpciaccess0 libpixman-1-0 libpq5 libprotobuf-lite9v5 libproxy1v5\n librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsctp1\n libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtiff5\n libtxc-dxtn-s2tc0 libvpx3 libwayland-client0 libwayland-cursor0\n libwayland-egl1-mesa libwayland-server0 libwxbase3.0-0v5 libwxgtk3.0-0v5\n libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0\n libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1\n libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxpm4\n libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1\n notification-daemon postgresql-client postgresql-client-9.5\n postgresql-client-common ubuntu-mono x11-common\n0 upgraded, 134 newly installed, 0 to remove and 19 not upgraded.\nNeed to get 84.2 MB of archives.\nAfter this operation, 285 MB of additional disk space will be used.\nWARNING: The following packages cannot be authenticated!\n esl-erlang elixir erlang-mode\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following additional packages will be installed:", " adwaita-icon-theme at-spi2-core colord colord-data dconf-gsettings-backend", " dconf-service emacsen-common erlang-mode fontconfig fontconfig-config", " fonts-dejavu-core glib-networking glib-networking-common", " glib-networking-services gsettings-desktop-schemas hicolor-icon-theme", " humanity-icon-theme libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data", " libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3", " libboost-filesystem1.58.0 libboost-system1.58.0 libcairo-gobject2 libcairo2", " libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1", " libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa", " libepoxy0 libexif12 libfontconfig1 libgbm1 libgd3 libgdk-pixbuf2.0-0", " libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa", " libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0", " libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common", " libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libjbig0", " libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common", " liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3", " libnotify4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0", " libpciaccess0 libpixman-1-0 libpq5 libprotobuf-lite9v5 libproxy1v5", " librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsctp1", " libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtiff5", " libtxc-dxtn-s2tc0 libvpx3 libwayland-client0 libwayland-cursor0", " libwayland-egl1-mesa libwayland-server0 libwxbase3.0-0v5 libwxgtk3.0-0v5", " libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0", " libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1", " libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxpm4", " libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1", " notification-daemon postgresql-client-9.5 postgresql-client-common", " ubuntu-mono x11-common", "Suggested packages:", " colord-sensor-argyll erlang erlang-manpages erlang-doc default-jre-headless", " | java2-runtime-headless | java1-runtime-headless | java2-runtime", " | java1-runtime cups-common libgd-tools gphoto2 gvfs liblcms2-utils", " librsvg2-bin avahi-daemon hplip libsane-extras sane-utils lksctp-tools", " postgresql-9.5 postgresql-doc-9.5", "The following NEW packages will be installed:", " adwaita-icon-theme at-spi2-core colord colord-data dconf-gsettings-backend", " dconf-service elixir emacsen-common erlang-mode esl-erlang fontconfig", " fontconfig-config fonts-dejavu-core glib-networking glib-networking-common", " glib-networking-services gsettings-desktop-schemas hicolor-icon-theme", " humanity-icon-theme libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data", " libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3", " libboost-filesystem1.58.0 libboost-system1.58.0 libcairo-gobject2 libcairo2", " libcolord2 libcolorhug2 libcroco3 libcups2 libdatrie1 libdconf1", " libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa", " libepoxy0 libexif12 libfontconfig1 libgbm1 libgd3 libgdk-pixbuf2.0-0", " libgdk-pixbuf2.0-common libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa", " libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgraphite2-3 libgtk-3-0", " libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common", " libgudev-1.0-0 libgusb2 libharfbuzz0b libice6 libieee1284-3 libjbig0", " libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common", " liblcms2-2 libllvm3.8 libltdl7 libmirclient9 libmircommon5 libmirprotobuf3", " libnotify4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0", " libpciaccess0 libpixman-1-0 libpq5 libprotobuf-lite9v5 libproxy1v5", " librest-0.7-0 librsvg2-2 librsvg2-common libsane libsane-common libsctp1", " libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtiff5", " libtxc-dxtn-s2tc0 libvpx3 libwayland-client0 libwayland-cursor0", " libwayland-egl1-mesa libwayland-server0 libwxbase3.0-0v5 libwxgtk3.0-0v5", " libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0", " libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1", " libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxpm4", " libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1", " notification-daemon postgresql-client postgresql-client-9.5", " postgresql-client-common ubuntu-mono x11-common", "0 upgraded, 134 newly installed, 0 to remove and 19 not upgraded.", "Need to get 84.2 MB of archives.", "After this operation, 285 MB of additional disk space will be used.", "WARNING: The following packages cannot be authenticated!", " esl-erlang elixir erlang-mode"]}