--- - name: "SSL cert" hosts: target tasks: - name: "Install ca-certificates" apt: pkg: "{{ item }}" state: present with_items: - ca-certificates when: ansible_distribution == "Ubuntu" - name: "Install ca-certificates" portage: package: "{{ item }}" update: yes changed_use: yes with_items: - app-misc/ca-certificates when: ansible_distribution == "Gentoo" - name: "Create self-signed SSL cert" shell: cmd: | if [ ! -f "/etc/ssl/certs/{{ item }}.crt" ] && [ ! -f "/etc/ssl/private/{{ item }}.key" ]; then openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:4096 -keyout "/tmp/{{ item }}.key" -out "/tmp/{{ item }}.crt" <