Copy files from Windows CIFS share to a Linux folder

In this post, I will show a playbook with different tasks to copy files from Windows CIFS shared folder to a Linux folder.

First, the status and the prerequisites:

  • I have 3 machines:
    • The Ansible controller ansible_srv01 where the playbook while be launched
    • The Windows machine win_srv01
    • The Linux machine lin_srv01
  • The data to copy is located in win_srv01 in the CIFS shared folder called : \\win_srv01\d$\src_data
  • The serveur win_srv01 is member of the Active Directory called mydom.local
  • Credentials to connect to the CIFS shared folder are:
    • user : cifs_user_readaccess
    • password : myS3cretPassword
  • The destination folder is located on lin_srv01 folder called /opt/my_dest

The steps to copy my files will be the following:

  • Create a temporary folder on lin_srv01 to act as a mountpoint for the CIFS shared folder : /tmp/my_tmp_mountpoint
  • Mount the CIFS shared folder
  • Copy data from win_srv01 to lin_srv01
  • Umount
  • Remove the mountpoint

And now the Ansible playbook:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social Media Auto Publish Powered By : XYZScripts.com
%d bloggers like this: