Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

pacman module

ANSIBLE VERSION

ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.13 (default, Feb 11 2017, 12:22:40) [GCC 6.3.1 20170109]

This worked fine in Ansible 2.2.

CONFIGURATION

[defaults]
nocows=1

OS / ENVIRONMENT

I'm running on Arch Linux

SUMMARY

Running

STEPS TO REPRODUCE

https://github.com/thomwiggers/odroid-playbooks/blob/master/roles/common/tasks/common.yml#L8-L16

EXPECTED RESULTS

Updated/installed packages

ACTUAL RESULTS

Crashes.

TASK [common : Install packages] ************************************************************************************************************************************************************************************************************
task path: /home/thom/git/stage/management/roles/common/tasks/common.yml:8
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/pacman.py
<homer> ESTABLISH SSH CONNECTION FOR USER: None
<homer> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/thom/.ansible/cp/fdc2bea664 homer '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<homer> (0, '/home/thom\n', "OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W '[%h]:%p' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<homer> ESTABLISH SSH CONNECTION FOR USER: None
<homer> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/thom/.ansible/cp/fdc2bea664 homer '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474 `" && echo ansible-tmp-1493382410.32-244000386629474="` echo /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474 `" ) && sleep 0'"'"''
<homer> (0, 'ansible-tmp-1493382410.32-244000386629474=/home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474\n', "OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W '[%h]:%p' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<homer> PUT /tmp/tmp3nwsZr TO /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/pacman.py
<homer> SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/thom/.ansible/cp/fdc2bea664 '[homer]'
<homer> (0, 'sftp> put /tmp/tmp3nwsZr /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/pacman.py\n', 'OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W \'[%h]:%p\' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "posix-rename@openssh.com" revision 1\r\ndebug2: Server supports extension "statvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "fstatvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "hardlink@openssh.com" revision 1\r\ndebug2: Server supports extension "fsync@openssh.com" revision 1\r\ndebug3: Sent message fd 5 T:16 I:1\r\ndebug3: SSH_FXP_REALPATH . -> /home/thom size 0\r\ndebug3: Looking up /tmp/tmp3nwsZr\r\ndebug3: Sent message fd 5 T:17 I:2\r\ndebug3: Received stat reply T:101 I:2\r\ndebug1: Couldn\'t stat remote file: No such file or directory\r\ndebug3: Sent message SSH2_FXP_OPEN I:3 P:/home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/pacman.py\r\ndebug3: Sent message SSH2_FXP_WRITE I:4 O:0 S:32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 4 32768 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:5 O:32768 S:27437\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 5 27437 bytes at 32768\r\ndebug3: Sent message SSH2_FXP_CLOSE I:4\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<homer> ESTABLISH SSH CONNECTION FOR USER: None
<homer> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/thom/.ansible/cp/fdc2bea664 homer '/bin/sh -c '"'"'chmod u+x /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/ /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/pacman.py && sleep 0'"'"''
<homer> (0, '', "OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W '[%h]:%p' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<homer> ESTABLISH SSH CONNECTION FOR USER: None
<homer> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/thom/.ansible/cp/fdc2bea664 -tt homer '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tixkiailijheyhbmsllbeczwqwdaiueq; /usr/bin/python /home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/pacman.py; rm -rf "/home/thom/.ansible/tmp/ansible-tmp-1493382410.32-244000386629474/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<homer> (0, 'Traceback (most recent call last):\r\n File "/tmp/ansible_nbtluy_z/ansible_module_pacman.py", line 451, in <module>\r\n main()\r\n File "/tmp/ansible_nbtluy_z/ansible_module_pacman.py", line 443, in main\r\n install_packages(module, pacman_path, p[\'state\'], pkgs, pkg_files)\r\n File "/tmp/ansible_nbtluy_z/ansible_module_pacman.py", line 306, in install_packages\r\n data = stdout.split(\'\\n\')[3].split(\' \')[2:]\r\nIndexError: list index out of range\r\n', "OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W '[%h]:%p' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 131.174.12.215 closed.\r\n")
failed: [homer] (item=[u'ack', u'base-devel', u'clang', u'cmake', u'cronie', u'curl', u'git', u'htop', u'ltrace', u'ntp', u'openbsd-netcat', u'python', u'python-pip', u'python-virtualenv', u'python-virtualenvwrapper', u'python2', u'python2-pip', u'rsync', u'strace', u'svn', u'the_silver_searcher', u'tmux', u'valgrind', u'vim', u'wget', u'zsh']) => {
"failed": true,
"item": [
"ack",
"base-devel",
"clang",
"cmake",
"cronie",
"curl",
"git",
"htop",
"ltrace",
"ntp",
"openbsd-netcat",
"python",
"python-pip",
"python-virtualenv",
"python-virtualenvwrapper",
"python2",
"python2-pip",
"rsync",
"strace",
"svn",
"the_silver_searcher",
"tmux",
"valgrind",
"vim",
"wget",
"zsh"
],
"module_stderr": "OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017\r\ndebug1: Reading configuration data /home/thom/.ssh/config\r\ndebug1: /home/thom/.ssh/config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256]\r\ndebug1: /home/thom/.ssh/config line 82: Applying options for homer\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -l twiggers -vvv -W '[%h]:%p' lilo.science.ru.nl\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7302\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 131.174.12.215 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_nbtluy_z/ansible_module_pacman.py\", line 451, in <module>\r\n main()\r\n File \"/tmp/ansible_nbtluy_z/ansible_module_pacman.py\", line 443, in main\r\n install_packages(module, pacman_path, p['state'], pkgs, pkg_files)\r\n File \"/tmp/ansible_nbtluy_z/ansible_module_pacman.py\", line 306, in install_packages\r\n data = stdout.split('\\n')[3].split(' ')[2:]\r\nIndexError: list index out of range\r\n",
"msg": "MODULE FAILURE",
"rc": 0
}

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

package

pacman

ANSIBLE VERSION

ansible 2.3.0.0
config file = /home/user/code/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.11 (default, Mar 20 2016, 15:46:50) [GCC 5.3.0]

OS / ENVIRONMENT

Host: Arch Linux

Node: Arch Linux

SUMMARY

The pacman and package modules fail with a Traceback when trying to install a non-existing package.

STEPS TO REPRODUCE

A playbook with the following content:

---
- hosts: all
tasks:
- name: Try to install a non-existing package
package:
name: thispackagedoesnotexist
state: latest

An inventory that references a single Arch Linux host.

EXPECTED RESULTS

A warning/error message that the package does not exist.

ACTUAL RESULTS

$ ansible-playbook -i inventories/development.ini installtraceback.yml
PLAY [all] ************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************
ok: [devel]

TASK [Try to install a non-existing package] **************************************************************************************************************************************************************************************************
fatal: [devel]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 192.168.122.125 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_nQG_Kl/ansible_module_pacman.py\", line 451, in <module>\r\n main()\r\n File \"/tmp/ansible_nQG_Kl/ansible_module_pacman.py\", line 443, in main\r\n install_packages(module, pacman_path, p['state'], pkgs, pkg_files)\r\n File \"/tmp/ansible_nQG_Kl/ansible_module_pacman.py\", line 306, in install_packages\r\n data = stdout.split('\\n')[3].split(' ')[2:]\r\nIndexError: list index out of range\r\n", "msg": "MODULE FAILURE", "rc": 0}
to retry, use: --limit @/home/user/code/ansible/installtraceback.retry

PLAY RECAP ************************************************************************************************************************************************************************************************************************************
devel : ok=1 changed=0 unreachable=0 failed=1