Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to configure custom SSL certificate for st2web/nginx #133

Merged
merged 2 commits into from
Apr 18, 2017

Conversation

arm4b
Copy link
Member

@arm4b arm4b commented Apr 14, 2017

Closes #132

Add 2 new vars for st2web role: st2web_ssl_certificate and st2web_ssl_certificate_key.
If both vars are provided, - save the cert. If not provided, - generate self-signed certificate as it was before.

The default behavior remains as before: generting self-signed cert for st2web UI,

Example usage

- name: Install StackStorm
  hosts: all
  roles:
    ...
    - name: Install st2web
      role: st2web
      vars:
        st2web_ssl_certificate: "{{ lookup('file', 'local/path/to/domain-name.crt') }}"
        st2web_ssl_certificate_key: "{{ lookup('file', 'local/path/to/domain-name.key') }}"

TODO

  • Verify for real with a custom cert

@arm4b arm4b added the feature label Apr 14, 2017
@arm4b arm4b requested a review from bigmstone April 14, 2017 02:17
@arm4b arm4b added the RFR label Apr 14, 2017
dest: /etc/ssl/st2
mode: 0700

- name: Save custom SSL certificate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@armab This would all be simple if ansible-st2 would allow galaxy imports so we could just use jdauphant's SSL role.

copy:
content: "{{ item.cert }}"
dest: "{{ item.path }}"
mode: 0600
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd explicitly set the owner and group just to be clear.

Copy link
Member Author

@arm4b arm4b Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.
Now wondering what user:group should it be.

Hmm, root:root or something different including mode, example: https://superuser.com/a/556496

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in e442ebf


- name: Generate self-signed SSL certificate
become: yes
shell: openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/st2/st2.key -out /etc/ssl/st2/st2.crt -days 365 -nodes -subj "/C=US/ST=California/L=Palo Alto/O=StackStorm/OU=Information Technology/CN=$(hostname)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this generate a new cert every time ansible is run? You may want to stat the file and check if the .crt and .key exist before regeneration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has creates arg below, so should be good.

Copy link
Contributor

@bigmstone bigmstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@arm4b arm4b merged commit 2be9ae7 into master Apr 18, 2017
@arm4b arm4b deleted the feature/st2web-custom-cert branch April 18, 2017 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants