On 2018-04-04, at 21:41:52 +0100, Jeremy Sowden wrote:
> Since upgrading Ansible to 2.5.0, it has been failing to gather facts
> on my servers which do not have dmidecode installed.  I diffed the
> 2.4.3 and 2.5.0 versions of
> ansible/module_utils/facts/virtual/linux.py and found the following
> change:
>
> @@ -220,6 +233,17 @@
>                  virtual_facts['virtualization_role'] = 'guest'
>                  return virtual_facts
>
> +        # In older Linux Kernel versions, /sys filesystem is not
> available
> +        # dmidecode is the safest option to parse virtualization
> related values

Obviously this bug doesn't affect Ansible when trying to gather facts
from newer hosts, since it does not fall back to trying to run
dmidecode.

I forgot to provide a test-case.  I've attached logs of failed and
successful attempts to gather facts from one of my amd64 servers.  The
only difference between the two attempts is that I installed dmidecode
before the successful one.

I've snipped the actual facts returned by the successful attempt.
[azazel@celephais:~/work/ansible] $ ssh kadath apt-cache policy dmidecode
dmidecode:
  Installed: (none)
  Candidate: 3.0-4
  Version table:
     3.0-4 500
        500 http://mirror.ox.ac.uk/debian stable/main amd64 Packages
        500 http://ftp.uk.debian.org/debian stable/main amd64 Packages
        500 http://ftp.debian.org/debian stable/main amd64 Packages
     2.12-3 500
        500 http://mirror.ox.ac.uk/debian oldstable/main amd64 Packages
        500 http://ftp.uk.debian.org/debian oldstable/main amd64 Packages
        500 http://ftp.debian.org/debian oldstable/main amd64 Packages
[azazel@celephais:~/work/ansible] $ cat inventories/dmidecode_test
[all]
  192.168.96.1
[azazel@celephais:~/work/ansible] $ cat dmidecode_test_playbook.yml
---
- hosts : all
  gather_facts : True

  vars :
  roles :
[azazel@celephais:~/work/ansible] $ ansible-playbook -vvv -i 
inventories/dmidecode_test dmidecode_test_playbook.yml
ansible-playbook 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/azazel/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.14+ (default, Mar 13 2018, 15:23:44) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /home/azazel/work/ansible/inventories/dmidecode_test inventory source 
with ini plugin
 _______________________________________
< PLAYBOOK: dmidecode_test_playbook.yml >
 ---------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

1 plays in dmidecode_test_playbook.yml
 ____________
< PLAY [all] >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ________________________
< TASK [Gathering Facts] >
 ------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

task path: /home/azazel/work/ansible/dmidecode_test_playbook.yml:2
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'echo ~ && sleep 0'"'"''
<192.168.96.1> (0, '/home/azazel\n', '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c '"'"'( 
umask 77 && mkdir -p "` echo 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391 `" && echo 
ansible-tmp-1522913112.18-247490260293391="` echo 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391 `" ) && 
sleep 0'"'"''
<192.168.96.1> (0, 
'ansible-tmp-1522913112.18-247490260293391=/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391\n',
 '')
<192.168.96.1> PUT 
/home/azazel/.ansible/tmp/ansible-local-29652szfdDu/tmpePQ_Xy TO 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/setup.py
<192.168.96.1> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 '[192.168.96.1]'
<192.168.96.1> (0, 'sftp> put 
/home/azazel/.ansible/tmp/ansible-local-29652szfdDu/tmpePQ_Xy 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/setup.py\n',
 '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'chmod u+x 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/ 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/setup.py && 
sleep 0'"'"''
<192.168.96.1> (0, '', '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 -tt 192.168.96.1 '/bin/sh -c 
'"'"'/usr/bin/python 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/setup.py && 
sleep 0'"'"''
<192.168.96.1> (1, '\r\n{"exception": "  File 
\\"/home/azazel/tmp/ansible_DYeKNH/ansible_modlib.zip/ansible/module_utils/basic.py\\",
 line 2798, in run_command\\n    cmd = subprocess.Popen(args, **kwargs)\\n  
File \\"/usr/lib/python2.7/subprocess.py\\", line 390, in __init__\\n    
errread, errwrite)\\n  File \\"/usr/lib/python2.7/subprocess.py\\", line 1024, 
in _execute_child\\n    raise child_exception\\n", "cmd": "None -s 
system-product-name", "failed": true, "rc": 2, "invocation": {"module_args": 
{"filter": "*", "gather_subset": ["all"], "fact_path": "/etc/ansible/facts.d", 
"gather_timeout": 10}}, "msg": "[Errno 2] No such file or directory"}\r\n', 
'Shared connection to 192.168.96.1 closed.\r\n')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'rm -f -r 
/home/azazel/.ansible/tmp/ansible-tmp-1522913112.18-247490260293391/ > 
/dev/null 2>&1 && sleep 0'"'"''
<192.168.96.1> (0, '', '')
The full traceback is:
  File 
"/home/azazel/tmp/ansible_DYeKNH/ansible_modlib.zip/ansible/module_utils/basic.py",
 line 2798, in run_command
    cmd = subprocess.Popen(args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception

fatal: [192.168.96.1]: FAILED! => {
    "changed": false,
    "cmd": "None -s system-product-name",
    "invocation": {
        "module_args": {
            "fact_path": "/etc/ansible/facts.d",
            "filter": "*",
            "gather_subset": [
                "all"
            ],
            "gather_timeout": 10
        }
    },
    "msg": "[Errno 2] No such file or directory",
    "rc": 2
}
        to retry, use: --limit 
@/home/azazel/work/ansible/dmidecode_test_playbook.retry
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

192.168.96.1               : ok=0    changed=0    unreachable=0    failed=1
[azazel@celephais:~/work/ansible] $ ssh kadath apt-cache policy dmidecode
dmidecode:
  Installed: 3.0-4
  Candidate: 3.0-4
  Version table:
 *** 3.0-4 500
        500 http://mirror.ox.ac.uk/debian stable/main amd64 Packages
        500 http://ftp.uk.debian.org/debian stable/main amd64 Packages
        500 http://ftp.debian.org/debian stable/main amd64 Packages
        100 /var/lib/dpkg/status
     2.12-3 500
        500 http://mirror.ox.ac.uk/debian oldstable/main amd64 Packages
        500 http://ftp.uk.debian.org/debian oldstable/main amd64 Packages
        500 http://ftp.debian.org/debian oldstable/main amd64 Packages
[azazel@celephais:~/work/ansible] $ cat inventories/dmidecode_test
[all]
  192.168.96.1
[azazel@celephais:~/work/ansible] $ cat dmidecode_test_playbook.yml
---
- hosts : all
  gather_facts : True

  vars :
  roles :
[azazel@celephais:~/work/ansible] $ ansible-playbook -vvv -i 
inventories/dmidecode_test dmidecode_test_playbook.yml
ansible-playbook 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/azazel/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.14+ (default, Mar 13 2018, 15:23:44) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /home/azazel/work/ansible/inventories/dmidecode_test inventory source 
with ini plugin
 _______________________________________
< PLAYBOOK: dmidecode_test_playbook.yml >
 ---------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

1 plays in dmidecode_test_playbook.yml
 ____________
< PLAY [all] >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ________________________
< TASK [Gathering Facts] >
 ------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

task path: /home/azazel/work/ansible/dmidecode_test_playbook.yml:2
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'echo ~ && sleep 0'"'"''
<192.168.96.1> (0, '/home/azazel\n', '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c '"'"'( 
umask 77 && mkdir -p "` echo 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907 `" && echo 
ansible-tmp-1522913247.18-237425965378907="` echo 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907 `" ) && 
sleep 0'"'"''
<192.168.96.1> (0, 
'ansible-tmp-1522913247.18-237425965378907=/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907\n',
 '')
<192.168.96.1> PUT 
/home/azazel/.ansible/tmp/ansible-local-29791r1g1A1/tmpvMrj_a TO 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/setup.py
<192.168.96.1> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 '[192.168.96.1]'
<192.168.96.1> (0, 'sftp> put 
/home/azazel/.ansible/tmp/ansible-local-29791r1g1A1/tmpvMrj_a 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/setup.py\n',
 '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'chmod u+x 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/ 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/setup.py && 
sleep 0'"'"''
<192.168.96.1> (0, '', '')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 -tt 192.168.96.1 '/bin/sh -c 
'"'"'/usr/bin/python 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/setup.py && 
sleep 0'"'"''
<192.168.96.1> (0, '\r\n{"invocation": {"module_args": {"filter": "*", 
"gather_subset": ["all"], "fact_path": "/etc/ansible/facts.d", 
"gather_timeout": 10}}, "ansible_facts": { /* snipped */ }}\r\n', 'Shared 
connection to 192.168.96.1 closed.\r\n')
<192.168.96.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.96.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o ConnectTimeout=10 -o 
ControlPath=/home/azazel/.ansible/cp/f62fa23a25 192.168.96.1 '/bin/sh -c 
'"'"'rm -f -r 
/home/azazel/.ansible/tmp/ansible-tmp-1522913247.18-237425965378907/ > 
/dev/null 2>&1 && sleep 0'"'"''
<192.168.96.1> (0, '', '')
ok: [192.168.96.1]
META: ran handlers
META: ran handlers
META: ran handlers
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

192.168.96.1               : ok=1    changed=0    unreachable=0    failed=0

Attachment: signature.asc
Description: PGP signature

Reply via email to