smb_client.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ---
  2. - name: Access an SMB share
  3. hosts: servera.lab.example.com
  4. become: true
  5. vars_files:
  6. - smb_vars.yml
  7. tasks:
  8. - name: the package to mount SMB shares is installed
  9. yum:
  10. name: cifs-utils
  11. state: present
  12. - name: the Linux group for Samba users exists
  13. group:
  14. name: "{{ allowed_group }}"
  15. - name: the Linux user for Samba exists
  16. user:
  17. name: "{{ samba_user }}"
  18. password: "{{ samba_user_password | password_hash('sha512', 'secretsalt') }}"
  19. groups:
  20. - "{{ allowed_group }}"
  21. - name: the credential file exists
  22. copy:
  23. content: "username={{ samba_usermount }}\n\
  24. password={{ samba_passmount }}\n"
  25. dest: /etc/samba/creds.txt
  26. owner: root
  27. group: root
  28. mode: '0600'
  29. no_log: true
  30. - name: the SMB share is mounted
  31. mount:
  32. path: "{{ mount_point }}"
  33. src: "//serverc.lab.example.com/{{ share_name }}"
  34. opts: "credentials=/etc/samba/creds.txt,multiuser,seal"
  35. state: mounted
  36. fstype: cifs