Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module apt with 'update_cache="yes"' not show stderr for "404 Not Found" errors #23155

Closed
galindro opened this issue Mar 30, 2017 · 2 comments · Fixed by #37410
Closed

Module apt with 'update_cache="yes"' not show stderr for "404 Not Found" errors #23155

galindro opened this issue Mar 30, 2017 · 2 comments · Fixed by #37410
Labels
affects_2.2 This issue/PR affects Ansible v2.2 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@galindro
Copy link

galindro commented Mar 30, 2017

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

apt

ANSIBLE VERSION
ansible 2.2.2.0
  config file = ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
[defaults]
host_key_checking = False
hostfile = /home/leeloo/inventory.ini
retry_files_enabled = False

[ssh_connection]
pipelining=True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ControlPath="~/.ansible/tmp/ansible-ssh-%h-%p-%r" -o UserKnownHostsFile=/dev/null
OS / ENVIRONMENT
# Ansible station: 
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.6 (jessie)
Release:	8.6
Codename:	jessie

#Managed station:
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.3 LTS
Release:	14.04
Codename:	trusty
SUMMARY

Is it possible to give the stderr on module apt when it fails to update the cache? When there is a 404 Not Found error, it always shows "msg": "Failed to update apt cache." and not the stderr. This is making impossible to use failed_when for error handling.

STEPS TO REPRODUCE
  1. On the remote machine, create this file /etc/apt/sources.list.d/ondrej-php5-precise.list with this content:
deb http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main
  1. Run this task
- name: Update apt
  apt:
    update_cache="yes"
EXPECTED RESULTS

A stderr with this content:

Err http://ppa.launchpad.net trusty/main amd64 Packages                        
  404  Not Found
Err http://ppa.launchpad.net trusty/main i386 Packages                         
  404  Not Found
ACTUAL RESULTS
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt.py
<150.162.1.113> ESTABLISH SSH CONNECTION FOR USER: leeloo
<150.162.1.113> SSH: EXEC sshpass -d13 ssh -vvv -o ControlMaster=auto -o ControlPersist=30m -o 'ControlPath=~/.ansible/tmp/ansible-ssh-%h-%p-%r' -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o User=leeloo -o ConnectTimeout=10 x.x.x.x '/bin/sh -c '"'"'sudo -H -S  -p "[sudo via ansible, key=eqbenuguebzshxqnneupcnpzevdouyti] password: " -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-eqbenuguebzshxqnneupcnpzevdouyti; /usr/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''

fatal: [x.x.x.x]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "failed_when_result": true, 
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false, 
            "autoremove": false, 
            "cache_valid_time": 0, 
            "deb": null, 
            "default_release": null, 
            "dpkg_options": "force-confdef,force-confold", 
            "force": false, 
            "install_recommends": null, 
            "only_upgrade": false, 
            "package": null, 
            "purge": false, 
            "state": "present", 
            "update_cache": true, 
            "upgrade": null
        }, 
        "module_name": "apt"
    }, 
    "msg": "Failed to update apt cache."
}
@galindro
Copy link
Author

According to http://docs.ansible.com/ansible/apt_module.html, it needs to return the bellow values:

image

But I think that it is ignored when we want to use apt only for update_cache:

module.fail_json(msg='Failed to update apt cache.')

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 feature_idea module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Mar 30, 2017
@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Mar 31, 2017
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot
Copy link
Contributor

ansibot commented Jul 18, 2017

@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants