diff --git a/mongodb-org-3.2/tasks/mongodb.yml b/mongodb-org-3.2/tasks/mongodb.yml index 35da6064..17466834 100644 --- a/mongodb-org-3.2/tasks/mongodb.yml +++ b/mongodb-org-3.2/tasks/mongodb.yml @@ -20,9 +20,14 @@ - name: Install the mongodb apt key apt_key: keyserver="hkp://keyserver.ubuntu.com:80" id={{ mongodb_repo_key }} state=present when: mongodb_install_from_external_repo + register: apt_key_update_cache + + - name: Update the apt cache after adding a new key + apt: update_cache=yes + when: apt_key_update_cache is changed - name: Remove the old mongo apt repositories - apt_repository: repo="{{ item }}" state=absent + apt_repository: repo="{{ item }}" state=absent update_cache=yes with_items: '{{ mongodb_old_repositories }}' when: mongodb_upgrade_from_older_version