Skip to content

how to deal with duplicate users in the userlists? #77

Open
@martbhell

Description

@martbhell

Consider this:

     adminusers:
       - {name: admin6, state: 'present', uid: 5006, group: "{{admingroup}}", shell: "{{adminshell}}" }
     moreusers:
       - {name: admin6, state: 'present', uid: 6011, group: "{{admingroup}}", generate_ssh_key: "yes", groups: ["bgroup"]  }

Quite easy to miss if you like me:

  • separate the two user lists into several yaml files.
  • exploded the yaml instead of having them on a single line like above

ansible-playbook --check does not complain with the above.

Without --check it sets admin6's uid to 6011 and the play changes them back and forth every run.

Thinking about different ways to prevent foot-shooting like this

Some random ideas:

  • Have a built-in task that fails the play if some of the keys are not unique.
    • name & uid comes to mind that really should be unique? Maybe also home.
  • Change / Also allow defining users in a single Dict instead of a list of Dicts?
    • There's some ansible.cfg that handles merges maybe worth thinking about if doing this
  • Maybe there's something one can do in the loop: thing to map / combine, possibly hard to read?
  • ??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions