volumes-v1.j2 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. {#
  2. Archetype: volumes-v1
  3. Description:
  4. Consolidated top-level volumes section supporting multiple modes:
  5. - Simple: Basic local volumes for standalone deployments
  6. - External: Reference pre-existing volumes
  7. - NFS: Network filesystem for shared storage in swarm
  8. - Swarm: Flexible mode supporting mount/local/NFS strategies
  9. Approach:
  10. - External volumes: No definition needed (external: true not used at top-level)
  11. - Standalone mode: Always uses local volumes
  12. - Swarm mode with mount: No volume definition (uses bind mounts)
  13. - Swarm mode with local: Simple local volumes
  14. - Swarm mode with NFS: Network filesystem with driver options
  15. Usage:
  16. Use as the single volumes archetype for all deployment types.
  17. Adapts based on volume_external, swarm_enabled, and swarm_volume_mode variables.
  18. #}
  19. {% if not volume_external %}
  20. {% if swarm_enabled %}
  21. {% if swarm_volume_mode in ['local', 'nfs'] %}
  22. volumes:
  23. {{ volume_name }}:
  24. {% if swarm_volume_mode == 'nfs' %}
  25. driver: local
  26. driver_opts:
  27. type: nfs
  28. o: addr={{ swarm_volume_nfs_server }},{{ swarm_volume_nfs_options }}
  29. device: ":{{ swarm_volume_nfs_path }}"
  30. {% endif %}
  31. {% endif %}
  32. {% else %}
  33. volumes:
  34. {{ volume_name }}:
  35. driver: local
  36. {% endif %}
  37. {% endif %}