Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. cat users-v2.yaml
  2. - name: Add users from users dictionary
  3. #action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.key }},{{ item.value.group }}" append=no
  4. action: user name={{ item.key }} password={{ item.value.password }} shell={{ item.value.shell }} state={{ item.value.state }} remove=yes update_password=on_create groups="{{ item.value.group }}" append=yes
  5. with_dict: users
  6. ignore_errors: yes
  7. - name: Add keys from users dictionary
  8. action: authorized_key user={{ item.key }} key="{{ item.value.ssh_key }}" exclusive=yes
  9. with_dict: users
  10. ###########
  11. cat newuser-user.yaml
  12. - hosts: all
  13. # remote_user: ec2-user
  14. sudo: yes
  15. sudo_user: root
  16.  
  17. vars_files:
  18. - newuser-users
  19. tasks:
  20. - copy: src=conf/custom-sudoers dest=/etc/sudoers.d/custom_sudoers owner=root group=root mode=644
  21. - group: name=default_group state=present
  22. - include: users-v2.yaml
  23. ##########
  24. cat newuser-users
  25. users:
  26. user1:
  27. password: MD5HASH
  28. shell: /bin/bash
  29. ssh_key: "{{ lookup('file', 'user1.pub') }}"
  30. state: present
  31. group: default_group
  32.  
  33. user2:
  34. password: MD5HASH
  35. shell: /bin/bash
  36. ssh_key: "{{ lookup('file', 'user2.pub') }}"
  37. state: present
  38. group: default_group
  39.  
  40. user3:
  41. password: MD5HASH
  42. shell: /bin/bash
  43. ssh_key: "{{ lookup('file', 'user3.pub') }}"
  44. state: present
  45. group: default_group
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement