Closed
Description
SUMMARY
openssh_keypair gives 'list index out of range'.
ansible@jumphost-test-jim:~/test$ ansible all -i hosts -m openssh_keypair -a "path=/home/scripts/test"
jumphost3 | FAILED! => {
"changed": false,
"msg": "list index out of range"
}
ISSUE TYPE
- Bug Report
COMPONENT NAME
openssh_keypair
ANSIBLE VERSION
$ ansible --version
ansible 2.8.0
config file = /home/ansible/test/ansible.cfg
configured module search path = [u'/home/ansible/.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
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
CONFIGURATION
$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/home/ansible/test/ansible.cfg) = [u'/home/ansible/test/hosts']
Hosts file:
[all]
jumphost3 ansible_connection=local ansible_python_interpreter=/usr/bin/python3
OS / ENVIRONMENT
$ uname -a
Linux jumphost-test-jim 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
STEPS TO REPRODUCE
ansible@jumphost-test-jim:~/test$ ansible all -i hosts -m openssh_keypair -a "path=/home/scripts/test owner=scripts group=scripts type=rsa size=4096"
jumphost3 | FAILED! => {
"changed": false,
"msg": "list index out of range"
}
ansible@jumphost-test-jim:~/test$ ansible all -i hosts -m openssh_keypair -a "path=/home/scripts/test owner=scripts group=scripts"
jumphost3 | FAILED! => {
"changed": false,
"msg": "list index out of range"
}
ansible@jumphost-test-jim:~/test$ ansible all -i hosts -m openssh_keypair -a "path=/home/scripts/test"
jumphost3 | FAILED! => {
"changed": false,
"msg": "list index out of range"
}
EXPECTED RESULTS
I expected a key to be generated.
ACTUAL RESULTS
$ ansible all -i hosts -m openssh_keypair -a "path=/home/scripts/test" -vvv
ansible 2.8.0
config file = /home/ansible/test/ansible.cfg
configured module search path = [u'/home/ansible/.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
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Using /home/ansible/test/ansible.cfg as config file
host_list declined parsing /home/ansible/test/hosts as it did not pass it's verify_file() method
script declined parsing /home/ansible/test/hosts as it did not pass it's verify_file() method
auto declined parsing /home/ansible/test/hosts as it did not pass it's verify_file() method
Parsed /home/ansible/test/hosts inventory source with ini plugin
META: ran handlers
<jumphost3> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<jumphost3> EXEC /bin/sh -c 'echo ~ansible && sleep 0'
<jumphost3> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758 `" && echo ansible-tmp-1560245886.28-137391518325758="` echo /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/crypto/openssh_keypair.py
<jumphost3> PUT /home/ansible/.ansible/tmp/ansible-local-18726LcvRUK/tmpt9TSlW TO /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758/AnsiballZ_openssh_keypair.py
<jumphost3> EXEC /bin/sh -c 'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758/ /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758/AnsiballZ_openssh_keypair.py && sleep 0'
<jumphost3> EXEC /bin/sh -c '/usr/bin/python3 /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758/AnsiballZ_openssh_keypair.py && sleep 0'
<jumphost3> EXEC /bin/sh -c 'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1560245886.28-137391518325758/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_openssh_keypair_payload_ur2cxe6f/__main__.py", line 304, in main
keypair.generate(module)
File "/tmp/ansible_openssh_keypair_payload_ur2cxe6f/__main__.py", line 167, in generate
if not self.isValid(module, perms_required=False) or self.force:
File "/tmp/ansible_openssh_keypair_payload_ur2cxe6f/__main__.py", line 208, in isValid
keysize = int(fingerprint[0])
jumphost3 | FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"comment": null,
"content": null,
"delimiter": null,
"directory_mode": null,
"follow": false,
"force": false,
"group": null,
"mode": null,
"owner": null,
"path": "/home/scripts/test",
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"size": null,
"src": null,
"state": "present",
"type": "rsa",
"unsafe_writes": null
}
},
"msg": "list index out of range"
}