Getting a file from a Samba server in an Ansible playbook
For a project I'm working on, I needed to make one of my Ansible playbooks grab an archived file off a Windows share using smbclient
.
There are a few concerns when doing something like this:
- There are a few required dependencies that need to be installed and configured.
- Unless you have a really insecure windows share, you need a username and password to access the share—and you should never put credentials into any kind of plaintext file!
- Many Windows-based environments also need the appropriate workgroup set in Samba's configuration file.
I'll dive right in and show you how to set up samba and grab a file from a share in an Ansible playbook: