Created
August 9, 2018 14:05
-
-
Save cjmatta/c3213b25af4a963b183def2a2a7c109a to your computer and use it in GitHub Desktop.
Ansible playbook to install shellinabox and secure it with a letsencrypt certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars: | |
certificate_email: [email protected] | |
domain_name: my.domain.com | |
become: yes | |
tasks: | |
- name: install certbot prereq | |
yum: | |
name: epel-release | |
state: present | |
- name: install packages | |
yum: | |
name: "{{ item.name }}" | |
state: present | |
with_items: | |
- { name: certbot } | |
- { name: "http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/s/shellinabox-2.20-5.el7.x86_64.rpm" } | |
- name: check if we already have cert | |
stat: | |
path: /etc/letsencrypt/live/{{ domain_name }} | |
register: certs | |
- name: get letsencrypt certs | |
command: certbot certonly -n --email {{ certificate_email }} --agree-tos --standalone -d {{ domain_name }} | |
when: certs.stat.exists == False | |
- name: create special combined cert file for shellinabox | |
shell: cat /etc/letsencrypt/live/{{ domain_name|quote }}/fullchain.pem /etc/letsencrypt/live/{{ domain_name|quote }}/privkey.pem > /var/lib/shellinabox/certificate.pem | |
- name: link certs | |
file: | |
src: /var/lib/shellinabox/certificate.pem | |
dest: /var/lib/shellinabox/certificate-{{ domain_name }}.pem | |
state: link | |
- name: set certificate permissions | |
file: | |
path: /var/lib/shellinabox/certificate.pem | |
owner: shellinabox | |
group: shellinabox | |
- name: enable shellinabox service | |
systemd: | |
name: shellinaboxd | |
enabled: yes | |
- name: restart shellinabox service | |
systemd: | |
name: shellinaboxd | |
state: restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment