diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index e1f53f269..a1227b0bb 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -307,6 +307,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): best_points = 0 for vhost in self.vhosts: + if vhost.modmacro is True: + continue if target_name in vhost.get_names(): points = 2 elif any(addr.get_addr() == target_name for addr in vhost.addrs): @@ -326,12 +328,27 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # No winners here... is there only one reasonable vhost? if best_candidate is None: # reasonable == Not all _default_ addrs - reasonable_vhosts = self._non_default_vhosts() + # remove mod_macro hosts from reasonable vhosts + reasonable_vhosts = self._without_modmacro( + self._non_default_vhosts()) if len(reasonable_vhosts) == 1: best_candidate = reasonable_vhosts[0] + if best_candidate is not None and best_candidate.modmacro is True: + return None return best_candidate + def _without_modmacro(self, vhosts): + """Return all non mod_macro vhosts + + :param vhosts: List of VirtualHosts + :type vhosts: (:class:`list` of :class:`~letsencrypt_apache.obj.VirtualHost`) + + :returns: List of VirtualHosts without mod_macro + :rtype: (:class:`list` of :class:`~letsencrypt_apache.obj.VirtualHost`) + """ + return [vh for vh in vhosts if vh.modmacro == False] + def _non_default_vhosts(self): """Return all non _default_ only vhosts.""" return [vh for vh in self.vhosts if not all(