jjneely

Local Accounts with Bcfg2

May 25th, 2011
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.68 KB | None | 0 0
  1. <?python
  2. passwd_lines = metadata.Probes["passwd"].splitlines()
  3. current_users = [line.split(':')[0] for line in passwd_lines]
  4. ?>
  5. <Bundle name='localaccounts' xmlns:py="http://genshi.edgewall.org/">
  6.         <py:for each="user in metadata.Properties['users.xml'].data.getchildren()">
  7.                 <py:if test="user.get('uid') not in current_users">
  8.                         <BoundAction name='addgroup'
  9.                                     timing='pre'
  10.                                     command='/usr/sbin/groupadd
  11.                                                --non-unique
  12.                                                --gid ${user.get("gidNumber")}
  13.                                                ${user.get("uid")}'
  14.                                     when='always'
  15.                                     status='check'/>
  16.                         <BoundAction name='adduser'
  17.                                     timing='pre'
  18.                                     command='/usr/sbin/useradd
  19.                                                --home ${user.get("homeDirectory")}
  20.                                                --shell ${user.get("loginShell")}
  21.                                                --uid ${user.get("uidNumber")}
  22.                                                --gid ${user.get("gidNumber")}
  23.                                                --comment "${user.get("gecos")}"
  24.                                                --non-unique
  25.                                                ${user.get("uid")}'
  26.                                     when='always'
  27.                                     status='check'/>
  28.                 </py:if>
  29.         </py:for>
  30. </Bundle>
Add Comment
Please, Sign In to add comment