You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/group/files/get_free_gid.py

24 lines
476 B
Python

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import grp
def main():
gids = [g.gr_gid for g in grp.getgrall()]
# Start the gid numbering with 1
# FreeBSD doesn't support the usage of gid 0, it doesn't fail (rc=0) but instead a number in the normal
# range is picked.
i = 1
while True:
if i not in gids:
print(i)
break
i += 1
if __name__ == '__main__':
main()