rax_cdb_user not idempotent?

17 views
Skip to first unread message

David Goodall

unread,
Jan 14, 2015, 9:31:22 AM1/14/15
to ansible...@googlegroups.com
Hi,

Using Tower 2.1 I have a playbook which creates a stack including a Cloud DB instance, user and DB.
This works fine, but on running the playbook again, it fails with:
msg: A user with the name "xxxxxxxxxx" already exists. 
(The username has special characters if that's any help).

I've pasted the YAML for creating the DB and user below - am I missing something obvious or is this module not idempotent?

Best regards,
David

    - name: Create cloud DB server
      rax_cdb:
        credentials: ~/.rax.creds
        region: LON
        name: "{{ db_server }}"
        flavor: 1
        volume: 2
        wait: yes
        state: present
      register: rax_db_server

    - name: Create cloud DB
      rax_cdb_database:
        credentials: ~/.rax.creds
        region: LON
        cdb_id: "{{rax_db_server.cdb.id}}"
        name: "{{ db_name }}"
        state: present
      register: rax_db_database

    - name: Create cloud DB user
      rax_cdb_user:
        credentials: ~/.rax.creds
        region: LON
        cdb_id: "{{rax_db_server.cdb.id}}"
        db_username: "{{ db_user }}"
        db_password: "{{ db_password }}"
        databases:
          - "{{rax_db_database.database.name}}"
        state: present
      register: rax_db_user

Matt Martz

unread,
Jan 14, 2015, 11:21:47 AM1/14/15
to ansible...@googlegroups.com
I have been unable to duplicate this issue.  The code in place in rax_cdb_user tries to perform a `instance.get_user` on the username.  If the username exists the user object is returned.  If an Exception is raised, the function returns False and the module attempts to create the user.

In your case, it sounds like the user does exist, but an Exception is being raised for some reason, that does not indicate the absence of a user.  You could try to make the following change to rax_cdb_user.py (which I may do anyway):


If that raises some other error, it might help track down why that user cannot be found on the instance.

--
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/a860e219-6775-43e6-9b85-b95a0e8e20c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

David Goodall

unread,
Jan 14, 2015, 12:20:00 PM1/14/15
to ansible...@googlegroups.com
Thank you Matt.
I made the change you suggested but still get the same result with no extra information.
I then tried a db username with no special characters and it works fine - sorry, I should have tried this first.

Here is the db username that doesn't work:
S+%{r.46Z?f_*JuB
The module can create a user with this name OK, but it fails on the 2nd run.
Not a problem for me at the moment as we will just use a different name.

Thanks again for your help.
Best regards,
David

Matt Martz

unread,
Jan 14, 2015, 2:34:44 PM1/14/15
to ansible...@googlegroups.com
David,

Thank you for the feedback.  I will look into this and see if it is a limitation of the API, pyrax or where ever else.  If I can find a solution I'll look into applying a fix.


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages