Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Useradd task
  2.  
  3. - hosts: service-all
  4. become: yes
  5. gather_facts: true
  6.  
  7. - name: User creation
  8. user: name="{{item.username}}"
  9. group="{{item.username if users_create_per_user_group
  10. else users_group}}"
  11. groups="{{item.groups | join(',')}}"
  12. shell={{item.shell if item.shell is defined else users_default_shell}}
  13. password="{{item.password if item.password is defined else '!'}}"
  14. comment="{{item.name}}"
  15. update_password="{{item.update_password if item_update_password is defined else users_update_password }}"
  16. uid="{{item.uid | default(omit) }}"
  17. createhome="{{'yes' if users_create_homedirs else 'no'}}"
  18. expires="{{item.expires | default(omit) }}"
  19. with_items: users
  20. tags: ['users','configuration']
  21.  
  22. group_vars/service-all
  23. users:
  24. - username: "{% if host in groups['service-prod'] and host in groups['service-mgmt'] %} '952292' {% elif host in groups['service-proj'] %} '9e2292' {% endif %}"
  25. name: test user
  26. groups: []
  27. uid: 2001
  28. ssh_key: []
  29. password: "{{ test_pass }}"
  30. expires: 1496501879
  31.  
  32. host
  33. [service-prod]
  34. Hostname1
  35. [service-mgmt]
  36. Hostname2
  37. [service-proj]
  38. Hostname3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement