ansible user module

183 views
Skip to first unread message

br...@antsmarching.net

unread,
May 14, 2014, 4:15:16 PM5/14/14
to ansible...@googlegroups.com
ok I have been working with the user module for the last week.  I really want to like ansible because it does not have any additional client requirements except ssh.  The problem I am having is that I am getting inconsistent results when using the user module. 

I add in the user to the play, and most of the time if I add a new user it will create it, but if I change the comment, or password, or shell or anything like that it is very unpredictable if it actually works, but it most likely will not work and will just give me the
: ok=2    changed=0    unreachable=0    failed=0
for all servers after a change was made to a play.

Example play file

---
- hosts: serverone:servertwo
  sudo: yes
  tasks:
  - name: add local user
    user: name=newguy comment="first last" uid=2222 group=users home=/home/newguy shell=/bin/bash password=$6$rounds=40000$SkYFjKIU7FhnFu2B$jGUr0hLkBeIB5Oi6kZyEcos3mwT78DfsW9LhDdd14Kx/T/VzYyyyyy     state=absent update_password=always  force=yes
    user: name=testtwo comment="test guy" uid=5002 group=users home=/home/testtwo shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TLNOVaXfyJsDPBCVMGWP/0tVCESX0IhdHUCuxQba2MUPwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes
    user: name=testthree comment="test guy" uid=5003 group=users home=/home/testthree shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TLNOVaXfyJsDPBCVMGWP/0tVCESX0IhdH4xjQbua72jMHUsPGwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes
    user: name=testfour comment="test guy" uid=5004 group=users home=/home/testfour shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TLNOVaXfyJsDPBCVMGWP/0tVCESX0IhdH4emCuxQua2jMHUsPGwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes
    user: name=testfive comment="test guy" uid=5005 group=users home=/home/testfive shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TLNOVaXfyJsDPBCVMGWP/0tVCESX0IhdH4eu72jMHUsPGwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes
    user: name=testsix comment="test what" uid=5006 group=users home=/home/testsix shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TLNOVaXfyJsDPBCVMGWP/0tVCESX0IhdH4emUa72jMHUsPGwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes
    user: name=testseven comment="test seven" uid=5007 group=users home=/home/testseven shell=/bin/bash password=$6$rounds=40000$3K4vP/lTWYvxKbLd$./c2g.TaXfyJsDPBCVMGWP/0tVCESX0IhdH4emU8CQbua72jMHUsPGwQLrqFUaKIfhkXsFqB13l0. state=present update_password=always  force=yes

Am I missing something, because according to the user doc the only field that is a requirement is "name" so ansible should be keying off that field, and all other fields should be able to change. 

I have tried removing all test* accounts from the systems and then run the play and one of two of the seven accounts are actually added back. 

Michael DeHaan

unread,
May 14, 2014, 6:20:15 PM5/14/14
to ansible...@googlegroups.com
What OS are you targetting and what ansible version are you using?




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/389bff9d-6b58-4ee1-8adf-0270f027bc5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

br...@antsmarching.net

unread,
May 15, 2014, 11:18:49 AM5/15/14
to ansible...@googlegroups.com
I am using ansible 1.5.5.  The server/clients are centos 6.5 and RHEL 6.5

James Cammarata

unread,
May 15, 2014, 6:35:04 PM5/15/14
to ansible...@googlegroups.com
You cannot specify multiple user entries under the one name. You need to modify it to do the following:

- name: add user1
  user: ...
- name: add user2
  user: ...
etc.



Michael DeHaan

unread,
May 15, 2014, 8:16:25 PM5/15/14
to ansible...@googlegroups.com

br...@antsmarching.net

unread,
May 16, 2014, 11:24:02 AM5/16/14
to ansible...@googlegroups.com
That is not the issue, the issue is that I am getting inconsistent results, and ansible is not changing the client after I change the playbook.  If some one is able to point out something in my playbook that I am doing wrong I can deal with that, but as far as I can tell I am setting it up correctly, but ansible is just missing when I make changes which is very scary problem to have.

Adam Morris

unread,
May 16, 2014, 11:45:27 AM5/16/14
to ansible...@googlegroups.com


On Friday, May 16, 2014 8:24:02 AM UTC-7, br...@antsmarching.net wrote:
That is not the issue, the issue is that I am getting inconsistent results, and ansible is not changing the client after I change the playbook.  If some one is able to point out something in my playbook that I am doing wrong I can deal with that, but as far as I can tell I am setting it up correctly, but ansible is just missing when I make changes which is very scary problem to have.


James already pointed out your issue (at least one of them)...
it should be :-

br...@antsmarching.net

unread,
May 16, 2014, 11:53:15 AM5/16/14
to ansible...@googlegroups.com
I thought James was just showing a different way of setting up the playbook.  Yes this fixes my issue.  Thank you very much for helping out with my problem.  The playbook appears to be working properly now.
Reply all
Reply to author
Forward
0 new messages