community.general/lib/ansible/modules/system
Sam Thursfield 5d2652f31b Fix authorized_key module crashing when given an invalid key
I tried a playbook with the following (accidentally wrong) task:

  tasks:
      - name: authorized key test
        authorized_key: key=/home/sam/.ssh/id_rsa.pub key_options='command="/foo/bar"' user=sam

I got the following traceback:

    TASK: [authorized key test] ***************************************************
    failed: [localhost] => {"failed": true, "parsed": false}
    Traceback (most recent call last):
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 2515, in <module>
        main()
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 460, in main
        results = enforce_state(module, module.params)
    File "/home/sam/.ansible/tmp/ansible-tmp-1427110003.65-277897441194582/authorized_key", line 385, in enforce_state
        parsed_new_key = (parsed_new_key[0], parsed_new_key[1], parsed_options, parsed_new_key[3])
    TypeError: 'NoneType' object has no attribute '__getitem__'

With this fix, I see the expected error instead:

    TASK: [authorized key test] ***************************************************
    failed: [localhost] => {"failed": true}
    msg: invalid key specified: /home/sam/.ssh/id_rsa.pub
2016-12-08 11:22:50 -05:00
..
__init__.py package files 2016-12-08 11:22:22 -05:00
authorized_key.py Fix authorized_key module crashing when given an invalid key 2016-12-08 11:22:50 -05:00
cron.py Update cron example for setting to run twice a day 2016-12-08 11:22:31 -05:00
group.py Add basic support for OSX groups. 2016-12-08 11:22:42 -05:00
hostname.py Add Linuxmint support in hostname module 2016-12-08 11:22:41 -05:00
mount.py Setting the actual passno and dump defaults, and warning user of consequences in nulling 2016-12-08 11:22:48 -05:00
ping.py file extensions! 2016-12-08 11:22:22 -05:00
seboolean.py file extensions! 2016-12-08 11:22:22 -05:00
selinux.py Set selinux state to 'permissive' for state=disabled 2016-12-08 11:22:35 -05:00
service.py In service_enable, the default of changed is True so we have to set it to False explicitly if it is False. 2016-12-08 11:22:46 -05:00
setup.py file extensions! 2016-12-08 11:22:22 -05:00
sysctl.py now handles non string values for sysctl 2016-12-08 11:22:38 -05:00
user.py Added HP-UX subclass 2016-12-08 11:22:47 -05:00