Ansible role to install a stand alone Nodejs Server SSL Cert (Only for Ubuntu Systems)
1.1.0
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install ansible
sudo npm install forever -g
ansible-galaxy install kennashka.ansible_nodejs_certbot
- Replace (12.345.678.90) with your target server ip/domain address in hosts file
- Add the file location to ssh pem key in hosts file (ex. ansible_ssh_private_key_file= directory/location/to/your/pem/key/file.pem)
- Another option way is using boto for accessing server
Replace File Variables With Targeted Host Machine, Default User (root permission is needed to run certain tasks), Your Web Domain Info, Nodejs App Folder Name, and Email
- hosts: addyourhost
remote_user: ubuntu
become: yes
vars:
domain_name: 'yoursite.com'
domain_name2: 'www.yoursite.com'
app_folder: 'nodeappfoldername'
letsencrypt_email: 'mail@yoursite.com'
- This ansible role is assuming you have the server file named as "app.js"
- Certbot Requires port 80 or 443 to be available
- Default location path name for app and remote user: (ex. '{{ app_directory_path }}/') can be update
- Default location path name for yourapp/public for certbot challenge:
path='{{ app_directory_path }}/public/.well-known/acme-challenge'
- Certbot expects that App is up and running for Certbot challenge (/.well-known/acme-challenge)
- This ansible role will automatically modify app.js file to start using https and restart server
ansible-playbook -i ./hosts tasks/certbot.yml