Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ---
  2. - hosts: new
  3. vars:
  4. - root_password: 'foo'
  5. - minerva_password: 'bar'
  6.  
  7. tasks:
  8. - name: Change root password
  9. user:
  10. name=root
  11. password={{ root_password }}
  12.  
  13. - name: Add user minerva
  14. user:
  15. name=minerva
  16. password={{ minerva_password }}
  17.  
  18. - name: Add SSH public keys to user minerva
  19. authorized_key:
  20. user=minerva
  21. key="{{ lookup('file', "../keys/id_rsa.pub") }}"
  22.  
  23. - name: Add user minerva to sudoers
  24. lineinfile:
  25. "dest=/etc/sudoers
  26. regexp="^minerva ALL"
  27. line="minerva ALL=(ALL) NOPASSWD: ALL"
  28. state=present
  29.  
  30. - name: Disallow root SSH access
  31. lineinfile:
  32. dest=/etc/ssh/sshd_config
  33. regexp="^PermitRootLogin"
  34. line="PermitRootLogin no"
  35. state=present
  36. notify:
  37. - restart sshd
  38.  
  39. - name: Disallow SSH password authentication
  40. lineinfile:
  41. dest=/etc/ssh/sshd_config
  42. regexp="^PasswordAuthentication"
  43. line="PasswordAuthentication no"
  44. state=present
  45. notify:
  46. - restart sshd
  47.  
  48. handlers:
  49. - name: restart sshd
  50. service:
  51. name=sshd
  52. state=restarted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement