ansible/ansible — pull request #3087 by trbs (2013-06-01 01:02:28+00:00)
Title: Add support for Open and NetBSD platforms for user and group modules

Adds subclasses for OpenBSD and NetBSD platforms for user and group modules.

These fix some slight differences on these platforms from Generic (Linux).

Also adds to user module a new login_class parameter for FreeBSD, OpenBSD and NetBSD. And adds the ``` if self.module.check_mode ``` check for FreeBSD in group

Test Tasks:

```
---

- name: create admin group
group: name=admin system=yes state=present

- name: make sure notroot is an admin
action: user name=notroot groups=admin append=yes

- name: Create server group
group: name=server gid=1010

- name: Create server2 group
group: name=server2 gid=1011

- name: Create server user
user: name=server uid=1010 comment="Server" home=/home/server group=server shell=/bin/bash

- name: Create server user
user: name=server uid=1010 comment="Server" home=/home/server groups=server2 shell=/bin/bash

- name: Create server user
user: name=server uid=1010 comment="Server" home=/home/server groups=server2,server shell=/bin/bash

- name: Create test123 group (should not exist)
group: name=test123 gid=6666

- name: Change gid for test123 group
group: name=test123 gid=6667

- name: Remove test123 group (should always exists at this point)
group: name=test123 state=absent

- name: Create test123 group (should not exist)
group: name=test123 gid=6666

- name: Create test123 user (should not exist)
user: name=test123 uid=6666 group=test123 groups=operator,games comment="test123" login_class=default shell=/bin/bash

- name: Change groups for test123 user
user: name=test123 groups=games

- name: Remove test123 user (should always exists at this point)
user: name=test123 state=absent remove=yes

- name: Remove test123 group (will exists for openbsd and netbsd since they don't remove the primary group during userdel)
group: name=test123 state=absent

```

Test Results:

```
PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [db1]
ok: [server]
ok: [freebsd]
ok: [netbsd]
ok: [openbsd]
ok: [web2]
ok: [web1]

TASK: [create admin group] ****************************************************
ok: [server]
ok: [db1]
ok: [freebsd]
ok: [web2]
ok: [web1]
ok: [openbsd]
ok: [netbsd]

TASK: [make sure notroot is an admin] *****************************************
ok: [server]
ok: [db1]
ok: [freebsd]
ok: [web1]
ok: [web2]
ok: [netbsd]
ok: [openbsd]

TASK: [Create server group] ***************************************************
ok: [db1]
ok: [server]
ok: [web1]
ok: [freebsd]
ok: [web2]
ok: [netbsd]
ok: [openbsd]

TASK: [Create server2 group] **************************************************
ok: [db1]
ok: [server]
ok: [freebsd]
ok: [openbsd]
ok: [web1]
ok: [web2]
ok: [netbsd]

TASK: [Create server user] ****************************************************
ok: [server]
ok: [db1]
ok: [freebsd]
ok: [web2]
ok: [netbsd]
ok: [web1]
ok: [openbsd]

TASK: [Create server user] ****************************************************
ok: [db1]
ok: [server]
ok: [netbsd]
ok: [freebsd]
ok: [web1]
ok: [web2]
ok: [openbsd]

TASK: [Create server user] ****************************************************
ok: [server]
ok: [db1]
ok: [freebsd]
ok: [web1]
ok: [netbsd]
ok: [web2]
ok: [openbsd]

TASK: [Create test123 group (should not exist)] *******************************
changed: [db1]
changed: [server]
changed: [freebsd]
changed: [web1]
changed: [web2]
changed: [openbsd]
changed: [netbsd]

TASK: [Change gid for test123 group] ******************************************
changed: [db1]
changed: [server]
changed: [freebsd]
changed: [openbsd]
changed: [web1]
changed: [web2]
changed: [netbsd]

TASK: [Remove test123 group (should always exists at this point)] *************
changed: [server]
changed: [db1]
changed: [freebsd]
changed: [web2]
changed: [netbsd]
changed: [web1]
changed: [openbsd]

TASK: [Create test123 group (should not exist)] *******************************
changed: [db1]
changed: [server]
changed: [freebsd]
changed: [web1]
changed: [web2]
changed: [netbsd]
changed: [openbsd]

TASK: [Create test123 user (should not exist)] ********************************
changed: [db1]
changed: [server]
changed: [freebsd]
changed: [web2]
changed: [netbsd]
changed: [web1]
changed: [openbsd]

TASK: [Change groups for test123 user] ****************************************
changed: [server]
changed: [db1]
changed: [netbsd]
changed: [freebsd]
changed: [web1]
changed: [web2]
changed: [openbsd]

TASK: [Remove test123 user (should always exists at this point)] **************
changed: [server]
changed: [db1]
changed: [freebsd]
changed: [web1]
changed: [web2]
changed: [openbsd]
changed: [netbsd]

TASK: [Remove test123 group (will exists for openbsd and netbsd since they don't remove the primary group during userdel)] ***
ok: [db1]
ok: [server]
ok: [freebsd]
ok: [web1]
changed: [netbsd]
ok: [web2]
changed: [openbsd]

PLAY RECAP ********************************************************************
db1 : ok=16 changed=7 unreachable=0 failed=0
freebsd : ok=16 changed=7 unreachable=0 failed=0
netbsd : ok=16 changed=8 unreachable=0 failed=0
openbsd : ok=16 changed=8 unreachable=0 failed=0
server : ok=16 changed=7 unreachable=0 failed=0
web1 : ok=16 changed=7 unreachable=0 failed=0
web2 : ok=16 changed=7 unreachable=0 failed=0
```