add_cockpit_user.yaml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Add the cockpit user for systems with cockpit installed
  3. hosts: all
  4. gather_facts: true
  5. become: True
  6. tasks:
  7. - name: populate package mgr facts
  8. package_facts:
  9. manager: auto
  10. - name: Add cockpit user if cockpit is installed
  11. user:
  12. name: "cockpit"
  13. comment: "cockpit user for web interface"
  14. create_home: false
  15. local: true
  16. group: "wheel"
  17. groups: "cockpit-ws"
  18. shell: "/sbin/nologin"
  19. create_home: false
  20. uid: "986"
  21. system: true
  22. password: "***CONTENTS REDACTED***"
  23. state: present
  24. when: "'cockpit' in ansible_facts.packages"
  25. - name: add cockpit to sudoers file w/o psswd
  26. sudoers:
  27. commands: ALL
  28. host: ALL
  29. name: cockpit-nopsswd
  30. nopassword: True
  31. state: present
  32. user: cockpit
  33. validation: detect
  34. when: "'cockpit' in ansible_facts.packages"
  35. - name: ensure account has nothing locking it
  36. shell: |
  37. usermod -U cockpit
  38. usermod -e "" cockpit
  39. chage -E -1 cockpit
  40. chage -I -1 cockpit
  41. exit 0
  42. args:
  43. executable: /bin/bash
  44. when: "'cockpit' in ansible_facts.packages"