--- - name: Stop Apache service: name: apache2 state: stopped - name: Ensure SSL certificate exists shell: "certbot certonly --agree-tos --email certs@susurrando.com -n --standalone -d {{ item.vhostname }}" args: creates: "/etc/letsencrypt/archive/{{ item.vhostname }}" when: - "'ssl' in item" - item['ssl'] with_items: "{{ vhosts }}" - name: Start Apache service: name: apache2 state: started