Skip to content

Instantly share code, notes, and snippets.

@elleryq
Created January 30, 2020 01:58
Show Gist options
  • Save elleryq/1f42bd77dfd0f5b261cebb13dd7703af to your computer and use it in GitHub Desktop.
Save elleryq/1f42bd77dfd0f5b261cebb13dd7703af to your computer and use it in GitHub Desktop.
Generate self-signed ssl certification
- name: Simply generating self-signed SSL certs
hosts: all
become: yes
become_method: sudo
tasks:
- name: backup old cert
command: mv /etc/nginx/ssl/nginx.crt /etc/nginx/ssl/nginx.crt.bak
- name: create self-signed SSL cert
command: openssl req -new -nodes -x509 -subj "/C=TW/ST=Taipei/L=Taiwan/O=Biotrump/CN={{ansible_fqdn}}" -days 3650 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt -extensions v3_ca creates=/etc/nginx/ssl/nginx.crt
notify: reload nginx
changed_when: true
handlers:
- name: reload nginx
service: name=nginx state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment