ansible/roles/letsencrypt/tasks/main.yml in subspace-0.3.0 vs ansible/roles/letsencrypt/tasks/main.yml in subspace-0.4.0

- old
+ new

@@ -32,59 +32,47 @@ get_url: url: "https://dl.eff.org/certbot-auto" dest: "{{certbot_dir}}/certbot-auto" mode: a+x - - name: Run default - become: true - command: "{{certbot_dir}}/certbot-auto certonly --email {{letsencrypt_email}} --domains {{([server_name] + server_aliases) | join(',')}} --apache --agree-tos --expand --non-interactive" + - name: shutdown webserver for standalone mode + debug: msg="Shutdown webserver" + notify: stop webserver + changed_when: true - - name: Enable mod_rewrite - become: true - apache2_module: - name: rewrite - state: present + - meta: flush_handlers + - name: "wait for webserver to stop" + wait_for: + port: 80 + delay: 1 + state: stopped - - name: Enable mod_ssl + - name: Run default + when: le_ssl_certs is not defined become: true - apache2_module: - name: ssl - state: present + command: "{{certbot_dir}}/certbot-auto certonly --email {{letsencrypt_email}} --domains {{([server_name] + server_aliases) | join(',')}} --standalone --agree-tos --expand --non-interactive" - - name: Create SSL Apache config + - name: Generate SSL Certificates + when: le_ssl_certs is defined become: true - template: - src: project-le-ssl.conf - dest: /etc/apache2/sites-available/{{project_name}}-le-ssl.conf - notify: apache restart + with_items: "{{le_ssl_certs}}" + command: "{{certbot_dir}}/certbot-auto certonly --email {{letsencrypt_email}} --domains {{item.domains | join(',')}} --cert-name {{item.cert_name}} --standalone --agree-tos --expand --non-interactive" - - name: Symlink {{project_name}}-le-ssl.conf to sites-enabled - become: true - file: - src: /etc/apache2/sites-available/{{project_name}}-le-ssl.conf - dest: /etc/apache2/sites-enabled/{{project_name}}-le-ssl.conf - state: link - notify: apache restart + - name: "Re-run apache rails_project to get SSL configuration" + when: apache2_installed is defined + include_role: + name: apache-rails - - name: Force redirect to https (1/2) - become: true - lineinfile: - dest: /etc/apache2/sites-available/{{project_name}}.conf - line: "RewriteEngine on" - state: present - insertbefore: "</VirtualHost>" - notify: apache restart + - name: "Re-run nginx rails_project to get SSL configuration" + when: nginx_installed is defined + include_role: + name: nginx-rails - - name: Force redirect to https (2/2) - become: true - lineinfile: - dest: /etc/apache2/sites-available/{{project_name}}.conf - line: "RewriteCond %{SERVER_NAME} ={{item}}\nRewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,NE,R=permanent]" - state: present - insertbefore: "</VirtualHost>" - with_items: "{{ ([server_name] + server_aliases) }}" - notify: apache restart + - name: start webserver after standalone mode + debug: msg="Startup webserver" + notify: start webserver + changed_when: true - name: Setup cron job to auto renew become: true cron: name: Auto-renew SSL