users.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. - name: Validate fdamstra user
  3. ansible.builtin.user:
  4. name: fdamstra
  5. state: present
  6. comment: Fred Damstra
  7. shell: /bin/bash
  8. append: yes # add groups, not replace
  9. groups:
  10. - sudo
  11. home: /home/fdamstra
  12. password: "{{ password }}"
  13. update_password: on_create
  14. - name: Create authorized key
  15. authorized_key:
  16. user: fdamstra
  17. state: present
  18. key: "{{ public_ssh_key }}"
  19. - name: Set nopassword for sudo group
  20. lineinfile:
  21. path: /etc/sudoers.d/20-sudo-group-nopasswd
  22. line: '%sudo ALL=(ALL) NOPASSWD: ALL'
  23. state: present
  24. mode: 0440
  25. create: yes
  26. validate: 'visudo -cf %s'
  27. - name: Install public key
  28. copy:
  29. dest: /home/fdamstra/.ssh/id_ed25519.pub
  30. content: "{{ public_ssh_key }}"
  31. mode: 0644
  32. owner: fdamstra
  33. - name: Install private key
  34. copy:
  35. dest: /home/fdamstra/.ssh/id_ed25519
  36. content: "{{ private_ssh_key }}"
  37. mode: 0600
  38. owner: fdamstra
  39. - name: Set up Environment
  40. become: yes
  41. become_user: fdamstra
  42. git:
  43. repo: ssh://git@git.monkeybox.org:2222/fdamstra/MyEnvironment.git
  44. dest: /home/fdamstra/MyEnvironment
  45. accept_hostkey: yes
  46. register: git_myenvironment
  47. when: skip_git == False
  48. - name: Create Environment Links
  49. become: yes
  50. become_user: fdamstra
  51. command:
  52. chdir: /home/fdamstra/MyEnvironment
  53. cmd: ./CreateLinks.sh
  54. when: skip_git == False and git_myenvironment.changed
  55. - name: Remove Ubuntu user
  56. ansible.builtin.user:
  57. name: ubuntu
  58. state: absent
  59. - name: Git Email
  60. community.general.git_config:
  61. name: user.email
  62. scope: global
  63. value: 'fred.damstra@gmail.com'
  64. - name: Git Name
  65. community.general.git_config:
  66. name: user.email
  67. scope: global
  68. value: 'fred.damstra@gmail.com [{{ inventory_hostname }}'