diff --git a/roles/mailman/files/import-mm2.py b/roles/mailman/files/import-mm2.py index 7b1bf89c79..100244b757 100755 --- a/roles/mailman/files/import-mm2.py +++ b/roles/mailman/files/import-mm2.py @@ -34,7 +34,14 @@ class Importer(object): self.existing_lists = [ l.strip() for l in cmdget(["sudo", "-u", "mailman", MAILMAN_BIN, "lists", "-q"]).split("\n") ] - self.excluded = opts.exclude.strip().split(",") + if opts.exclude: + self.excluded = opts.exclude.strip().split(",") + else: + self.excluded = [] + if opts.include: + self.included = opts.include.strip().split(",") + else: + self.included = [] def _get_index_path(self): return None @@ -49,10 +56,15 @@ class Importer(object): if not d.startswith(".") ] all_listnames.sort() for index, listname in enumerate(all_listnames): - listaddr = "%s@%s" % (listname, self.config["domain"]) + listaddr = "%s@%s" % (listname, self.opts.domain.strip()) if listname in self.excluded or listaddr in self.excluded: print("Skipping excluded list %s" % listaddr) continue + if self.included and ( + listname not in self.included and + listaddr not in self.included): + print("Skipping not included list %s" % listaddr) + continue print(listaddr, "(%d/%d)" % (index+1, len(all_listnames))) confpickle = os.path.join(mm2libdir, 'lists', listname, 'config.pck') @@ -97,11 +109,20 @@ def main(): help="Don't import the archives, only import the list config") parser.add_option("-c", "--config", default="/etc/mailman-migration.conf", help="Configuration file (default: %defaults)") + parser.add_option("-d", "--domain", + help="Domain for the mailing-lists") parser.add_option("-x", "--exclude", default="", help="Comma-separated list of lists to exclude") + parser.add_option("-i", "--include", default="", + help="Comma-separated list of lists to include, no other " + "list will be imported") opts, args = parser.parse_args() if len(args) != 1: parser.error("Only one arg: the Mailman 2.1 lib dir to import") + if opts.include and opts.exclude: + parser.error("Only one of 'include' or 'exclude' may be used") + if not opts.domain: + parser.error("You must provide a domain name for the lists (--domain)") mm2libdir = args[0] if not os.path.exists(mm2libdir): diff --git a/roles/mailman/templates/mailman-hyperkitty.cfg.j2 b/roles/mailman/files/mailman-hyperkitty.cfg similarity index 75% rename from roles/mailman/templates/mailman-hyperkitty.cfg.j2 rename to roles/mailman/files/mailman-hyperkitty.cfg index 38563c9a66..04ede2adb2 100644 --- a/roles/mailman/templates/mailman-hyperkitty.cfg.j2 +++ b/roles/mailman/files/mailman-hyperkitty.cfg @@ -15,11 +15,6 @@ # better if it is not. base_url: http://localhost/archives/ -# This is the public URL of your HyperKitty installation. This value will -# appear as a link at the bottom of emails sent to the list, so it must be -# publicly accessible. -public_url: http://{{ mailman_url }}/archives/ - # Shared API key, must be the identical to the value in HyperKitty's # settings. api_key: SecretArchiverAPIKey diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml index 75ad5862e8..3fd30289d5 100644 --- a/roles/mailman/tasks/main.yml +++ b/roles/mailman/tasks/main.yml @@ -319,9 +319,9 @@ # Plug HyperKitty into Mailman # - name: copy the mailman-hyperkitty conffile - template: src=mailman-hyperkitty.cfg.j2 - dest="{{ mailman_webui_confdir }}/mailman-hyperkitty.cfg" - owner=root group=mailman mode=0640 + copy: src=mailman-hyperkitty.cfg + dest="{{ mailman_webui_confdir }}/mailman-hyperkitty.cfg" + owner=root group=mailman mode=0640 tags: - config - mailman