- name: Check if domain exists uri: url: 'http://localhost:8001/3.1/domains/{{ mm_site.listdomain }}' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: GET body_format: json status_code: [200, 404] register: domain_exists no_log: true - name: Create list domain in mm3 when: domain_exists.status == 404 uri: url: 'http://localhost:8001/3.1/domains' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: POST body_format: json body: mail_host: "{{ mm_site.listdomain }}" status_code: [201] no_log: true - name: Check if list exists uri: url: 'http://localhost:8001/3.1/lists/{{ mm_list.name }}@{{ mm_site.listdomain }}' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: GET body_format: json status_code: [200, 404] register: list_exists loop: "{{ mm_site.lists }}" loop_control: loop_var: mm_list no_log: true - name: Create lists in mm3 when: list_exists.results[exists_idx].status == 404 uri: url: 'http://localhost:8001/3.1/lists' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: POST body_format: json body: fqdn_listname: "{{ mm_list.name }}@{{ mm_site.listdomain }}" style_name: "{{ mm_list.private | default('false') | bool | ternary('private-default', 'legacy-default') }}" status_code: [201] loop: "{{ mm_site.lists }}" loop_control: loop_var: mm_list index_var: exists_idx no_log: true - name: Set list properties in mm3 when: list_exists.results[exists_idx].status == 404 uri: url: 'http://localhost:8001/3.1/lists/{{ mm_list.name }}@{{ mm_site.listdomain }}/config' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: PATCH body_format: json body: description: "{{ mm_list.description }}" advertised: "{{ mm_list.private | default('false') | bool | ternary('false', 'true') }}" # TODO enable this when lynx is present on the container images # convert_html_to_plaintext: "true" process_bounces: "false" filter_extensions: - "exe" - "bat" - "cmd" - "com" - "pif" - "scr" - "vbs" - "cpl" pass_types: - "multipart/mixed" - "multipart/alternative" - "text/plain" status_code: [204] loop: "{{ mm_site.lists }}" loop_control: loop_var: mm_list index_var: exists_idx no_log: true - name: Set list owner in mm3 when: list_exists.results[exists_idx].status == 404 uri: url: 'http://localhost:8001/3.1/members' url_username: restadmin url_password: "{{ mailman3_rest_password }}" force_basic_auth: yes method: POST body_format: json body: list_id: "{{ mm_list.name }}.{{ mm_site.listdomain }}" subscriber: "{{ mm_list.owner }}" role: "owner" status_code: [201] loop: "{{ mm_site.lists }}" loop_control: loop_var: mm_list index_var: exists_idx no_log: true