add_bacula_user.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ---
  2. - name: Add bacula user to enable control by Bacula/Bacularis system
  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: output package facts
  11. debug:
  12. msg:
  13. # - "{{ ansible_facts ['distribution_file_variety'] }}"
  14. - name: "install pkg containing lgroupmod, required by module(s) below"
  15. package:
  16. name: libuser
  17. state: present
  18. #when: "'libuser' not in ansible_facts.packages"
  19. - name: Add bacula user, Deb-like
  20. user:
  21. name: bacula
  22. comment: "Debian-like- Add bacula user for the Bacula backup system"
  23. create_home: true
  24. local: true
  25. group: "sudo"
  26. shell: "/bin/bash"
  27. uid: "133"
  28. system: false
  29. generate_ssh_key: false
  30. password: "$6$0000000000000000$00000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  31. expires: -1
  32. password_expire_max: 99999
  33. password_expire_min: 0
  34. password_lock: false
  35. state: present
  36. when: ansible_facts['distribution_file_variety'] == "Debian"
  37. - name: Add bacula user, RH-like
  38. user:
  39. name: bacula
  40. comment: "RH-like- Add bacula user for the Bacula backup system"
  41. create_home: true
  42. local: false
  43. group: "wheel"
  44. shell: "/bin/bash"
  45. uid: "133"
  46. system: true
  47. generate_ssh_key: false
  48. password: "$6$0000000000000000$00000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  49. expires: -1
  50. password_expire_max: 99999
  51. password_expire_min: 0
  52. password_lock: false
  53. state: present
  54. when: ansible_facts['distribution_file_variety'] == "RedHat"
  55. - name: Add bacula user to the sudoers file
  56. sudoers:
  57. commands: ALL
  58. host: ALL
  59. name: bacula
  60. nopassword: True
  61. state: present
  62. user: bacula
  63. validation: detect
  64. - name: Copy bacula RSA public keys to ~/bacula/.ssh/authorized_keys
  65. authorized_key:
  66. user: bacula
  67. comment: "RSA- ssh keys for the bacula backup user"
  68. key: "{{ lookup('file', '~/playbooks/bacula/include/bacula-id_rsa.pub') }}"
  69. state: present
  70. - name: copy bacula ECDSA public keys to ~/bacula/.ssh/authorized_keys
  71. authorized_key:
  72. user: bacula
  73. comment: "ECDSA- ssh keys for the bacula backup user"
  74. key: "{{ lookup('file', '~/playbooks/bacula/include/bacula-id_ecdsa.pub') }}"
  75. state: present
  76. - name: copy bacula ED25519 public keys to ~/zabbix/.ssh/authorized_keys
  77. authorized_key:
  78. user: bacula
  79. comment: "ED25519- ssh keys for the backup user"
  80. key: "{{ lookup('file', '~/playbooks/bacula/include/bacula-id_ed25519.pub') }}"
  81. state: present