Ansible role for configuring a Synology NAS running DSM
ansible-synology-dsm
is an Ansible role for configuring a Synology NAS running DSM. It leverages the Synology API to manage various services and settings.
- Ansible 2.6 or higher
- Access to a Synology NAS with DSM
-
Create a Requirements File: Create a
requirements.yml
file in your Ansible project directory with the following content:- src: https://github.com/agaffney/ansible-synology-dsm name: ansible-synology-dsm
-
Install the Role Using
ansible-galaxy
: Install the role directly from the GitHub repository by running:ansible-galaxy install -r requirements.yml
-
Reference the Role in Your Playbook: Once installed, reference the role in your playbook:
- hosts: synology_nas roles: - ansible-synology-dsm
Replace
synology_nas
with the appropriate host or group in your Ansible inventory.
This method allows you to easily incorporate the role into your Ansible workflows without needing it to be available on Ansible Galaxy.
Establishes a session with the NAS for subsequent API requests.
- include_tasks: login.yml
- name: Configure File Services
hosts: synology_nas
roles:
- ansible-synology-dsm
vars:
synology_dsm_nfs_enable: true # Enable NFS
synology_dsm_smb_enable: true # Enable SMB
synology_dsm_afp_enable: false # Disable AFP
- name: Configure Terminal Services
hosts: synology_nas
roles:
- ansible-synology-dsm
vars:
synology_dsm_ssh_enable: true # Enable SSH
synology_dsm_ssh_port: 22 # Set SSH port
synology_dsm_telnet_enable: false # Disable Telnet
- name: Configure User Services
hosts: synology_nas
roles:
- ansible-synology-dsm
vars:
synology_dsm_user_home_service_enable: true # Enable User Home Service
synology_dsm_user_home_location: "/volume1/homes" # Set home directory location
synology_dsm_user_home_enable_recycle_bin: false # Disable recycle bin for user homes
- name: Add Package Sources
hosts: synology_nas
roles:
- ansible-synology-dsm
vars:
synology_dsm_package_sources:
- name: "Example Source"
feed: "http://example.com/package/source"
Contributions are welcome. Please submit pull requests for any enhancements.