title: Ansible X509 certificate missing Subject Alternative Name
body: <p>I'am using Vagrant and Ansible roles to generate an SSL/TLS certificate but no matter what I try, the generated certificates is missing the Subject Alternative Name:</p>
  
  <pre><code>- name: Create an SSL security key &amp; CSR (Certificate Signing Request)    
    shell: openssl req -new -newkey rsa:2048 -nodes -keyout /etc/apache2/ssl/{{ item.host }}.key -subj "/subjectAltName=DNS.1={{ item.host }}, DNS.2=www.{{ item.host }}, IP.1=192.168.33.11/C={{params['ssl'].country_name}}/ST={{params['ssl'].state}}/L={{params['ssl'].locality}}/O={{params['ssl'].organization}}/CN={{ item.host }}" -out /etc/apache2/ssl/{{ item.host }}.csr
    args:
      executable: "/bin/bash"
    with_items: "{{params['vhosts']}}"
    when: item.ssl is defined and item.ssl
  </code></pre>
  
  <p>The certificate files gets generated but they Google Chrome always says </p>
  
  <p><strong><code>Subject Alternative Name Missing</code></strong></p>
  
  <p>This is the debug of my environment:</p>
  
  <pre><code>$ openssl version
  OpenSSL 1.0.2l  25 May 2017
  
  $ openssl x509 -noout -text -in /etc/apache2/ssl/myhost.dev.crt
  Certificate:
      Data:
          Version: 1 (0x0)
          Serial Number:
              a2:77:35:c7:6a:72:35:22
      Signature Algorithm: sha256WithRSAEncryption
          Issuer: subjectAltName=DNS.1=myhost.dev, DNS.2=www.myhost.dev, IP.1=192.168.33.11, C=DE, ST=Berlin, L=Berlin, O=Ltd, CN=myhost.dev
          Validity
              Not Before: Jun 12 15:36:58 2017 GMT
              Not After : Jun 10 15:36:58 2027 GMT
          Subject: subjectAltName=DNS.1=myhost.dev, DNS.2=www.myhost.dev, IP.1=192.168.33.11, C=DE, ST=Berlin, L=Berlin, O=Ltd, CN=myhost.dev
  </code></pre>