diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index 84179e146966b18a738d6872709bfe40661e56fb..3a66e9f2a60f060da38cac16e71de2d5f5fb7989 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -328,6 +328,11 @@
                 'anyOf': [
                     {
                         'properties': {
+                            'hash_length': {
+                                'type': 'integer',
+                                'minimum': 0,
+                                'default': 7
+                            },
                             'whitelist': {'$ref': '#/definitions/array_of_strings'},
                             'blacklist': {'$ref': '#/definitions/array_of_strings'},
                             'naming_scheme': {
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 068179c0cee8be3e9d84c98402e568ed0ffd3d79..82016feb843b32a2ed745a8f578ac3b591c9bebf 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -188,6 +188,7 @@ def parse_config_options(module_generator):
     #####
 
     # Automatic loading loads
+    module_file_actions['hash_length'] = module_configuration.get('hash_length', 7)
     module_file_actions['autoload'] = dependencies(
         module_generator.spec, module_file_actions.get('autoload', 'none'))
     # Prerequisites
@@ -295,7 +296,9 @@ def use_name(self):
             if constraint in self.spec:
                 suffixes.append(suffix)
         # Always append the hash to make the module file unique
-        suffixes.append(self.spec.dag_hash())
+        hash_length = configuration.pop('hash_length', 7)
+        if hash_length != 0:
+            suffixes.append(self.spec.dag_hash(length=hash_length))
         name = '-'.join(suffixes)
         return name
 
@@ -338,7 +341,7 @@ def blacklisted(self):
 
         return False
 
-    def write(self):
+    def write(self, overwrite=False):
         """
         Writes out a module file for this object.
 
@@ -399,6 +402,15 @@ def write(self):
         for line in self.module_specific_content(module_configuration):
             module_file_content += line
 
+        # Print a warning in case I am accidentally overwriting
+        # a module file that is already there (name clash)
+        if not overwrite and os.path.exists(self.file_name):
+            message = 'Module file already exists : skipping creation\n'
+            message += 'file : {0.file_name}\n'
+            message += 'spec : {0.spec}'
+            tty.warn(message.format(self))
+            return
+
         # Dump to file
         with open(self.file_name, 'w') as f:
             f.write(module_file_content)