Skip to content

user.present blows up if groups argument is specifed #4173

Closed
yml opened this Issue Mar 20, 2013 · 6 comments

2 participants

@yml
yml commented Mar 20, 2013
$ sudo -E salt-call state.single user.present foo shell="/bin/bash" home="/home/foo" groups="[www-data,sudo]"
[INFO    ] Loaded configuration file: /etc/salt/minion
[INFO    ] Executing command 'ps -efH' in directory '/home/ubuntu'
[INFO    ] Loading fresh modules for state activity
[INFO    ] Executing state user.present for foo
[ERROR   ] No changes made for foo
local:
----------
    State: - user
    Name:      foo
    Function:  present
        Result:    False
        Comment:   An exception occured in this state: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1205, in call
    ret = self.states[cdata['full']](*cdata['args'])
  File "/usr/lib/python2.7/dist-packages/salt/states/user.py", line 305, in present
    groups.extend(present_optgroups)
TypeError: 'NoneType' object is not iterable

        Changes:   

This is with salt 0.13.3-1

@yml
yml commented Mar 20, 2013

The state looks like this :

{% for usr in 'foo','bar','harm' %}                                                                                                                                       
{{ usr }}:                                                                       
    user.present:                                                                
        - shell: /bin/bash                                                       
        - home: /home/{{ usr }}                                                  
        - groups:                                                                
            - www-data                                                           
            - sudo                                                               
            - devs                                                               
        - require:                                                               
            - group: devs                                                        
    ssh_auth.present:                                                            
        - user: {{ usr }}                                                        
        - source: salt://repo/{{ usr }}.pub                       
        - require:                                                               
            - user: {{ usr }}                                                    
{% endfor %}
@yml
yml commented Mar 20, 2013

This seems to be fixed here : 0042ac2

This does not explain why groups is empty at that stage

@thatch45
Salt Stack member

Fixed in 0042ac2

Thanks for the report @yml

@thatch45 thatch45 closed this Mar 20, 2013
@yml
yml commented Mar 21, 2013

@thatch45 not sure it is fixed in 0042ac2 this is the same place where I have left a comment.

line 306

groups.extend(present_optgroups)

If present_optgroups isNone` is is going to raise an exception:

TypeError: 'NoneType' object is not iterable
@thatch45
Salt Stack member

Thanks, I just pushed a fix for it:
f042f85

@yml
yml commented Mar 22, 2013

I confirm that this one is fixed. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.