Skip to content

Commit

Permalink
SSL support
Browse files Browse the repository at this point in the history
  • Loading branch information
inkatze committed Feb 8, 2016
1 parent c03c4d1 commit c071902
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ Thumbs.db
# Tools and Framework files #
#############################
.vagrant

# Specific #
############

files
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

v3.0.0

- Feature: SSL support.
- Feature: Management and Undertow ports are now configurable.
- Removed management user override logic.

v2.1.0

- Updated default version to 10.0.0.Final.
Expand Down
55 changes: 50 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,35 @@ Defaults:

wildfly_bind_address: 0.0.0.0
wildfly_management_bind_address: 0.0.0.0
wildfly_manage_port: 9990
wildfly_manage_http_port: 9990
wildfly_manage_https_port: 9993
wildfly_http_port: 8080

wildfly_management_user: admin
wildfly_management_password: admin
wildfly_management_user_overwrite: yes
wildfly_https_port: 8443

wildfly_enable_ssl: no
wildfly_keystore_name: my.jks
wildfly_keystore_path: "{{ wildfly_dir }}/standalone/configuration/\
{{ wildfly_keystore_name }}"
wildfly_keystore_alias: my
wildfly_keystore_password: "secret"
wildfly_key_password: "secret"
wildfly_application_ssl_identity: '
<server-identities>
<ssl>
<keystore path="{{ wildfly_keystore_name }}"
relative-to="jboss.server.config.dir"
alias="{{ wildfly_keystore_alias }}"
keystore-password="{{ wildfly_keystore_password }}"
key-password="{{ wildfly_key_password }}"/>
</ssl>
</server-identities>'
wildfly_https_listener: '
<https-listener name="https-server" socket-binding="https"
security-realm="ManagementRealm"/>'

# Manually defined variables
# wildfly_management_user: admin
# wildfly_management_password: admin

Example Playbook
----------------
Expand All @@ -58,6 +81,28 @@ Example Playbook
roles:
- { role: inkatze.wildfly }

Admin User
----------

It's recommended that you create Wildfly's admin user separately as follows:

$ ansible-playbook main.yml --extra-vars "wildfly_management_user=admin wildfly_management_password=admin"

SSL Support
-----------

In order to enable SSL for applications and the management interface you have
to set the `wildfly_enable_ssl` variable to `yes` and put the keystore file
into this role files folder.

You can create a self signed keystore file with the following command:

$ keytool -genkey -alias mycert -keyalg RSA -sigalg MD5withRSA -keystore my.jks -storepass secret -keypass secret -validity 9999

It's recommended that the first and last name is your hostname. After this file
is created, you have to set the keystore related variable in order to work
correctly.

Troubleshooting
---------------

Expand Down
29 changes: 24 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,28 @@ wildfly_init_dir: /etc/init.d

wildfly_bind_address: 0.0.0.0
wildfly_management_bind_address: 0.0.0.0
wildfly_manage_port: 9990
wildfly_manage_http_port: 9990
wildfly_manage_https_port: 9993
wildfly_http_port: 8080

wildfly_management_user: admin
wildfly_management_password: admin
wildfly_management_user_overwrite: yes
wildfly_https_port: 8443

wildfly_enable_ssl: no
wildfly_keystore_name: my.jks
wildfly_keystore_path: "{{ wildfly_dir }}/standalone/configuration/\
{{ wildfly_keystore_name }}"
wildfly_keystore_alias: my
wildfly_keystore_password: "secret"
wildfly_key_password: "secret"
wildfly_application_ssl_identity: '
<server-identities>
<ssl>
<keystore path="{{ wildfly_keystore_name }}"
relative-to="jboss.server.config.dir"
alias="{{ wildfly_keystore_alias }}"
keystore-password="{{ wildfly_keystore_password }}"
key-password="{{ wildfly_key_password }}"/>
</ssl>
</server-identities>'
wildfly_https_listener: '
<https-listener name="https-server" socket-binding="https"
security-realm="ManagementRealm"/>'
24 changes: 20 additions & 4 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
- restart wildfly
- change standalone data mode

- name: Open wildfly management tcp port
firewalld: port={{ wildfly_manage_port }}/tcp permanent=true immediate=true
- name: Open wildfly management http tcp port
firewalld: port={{ wildfly_manage_http_port }}/tcp permanent=true immediate=true
state=enabled

- name: Open wildfly management udp port
firewalld: port={{ wildfly_manage_port }}/udp permanent=true immediate=true
- name: Open wildfly management http udp port
firewalld: port={{ wildfly_manage_http_port }}/udp permanent=true immediate=true
state=enabled

- name: Open wildfly management https tcp port
firewalld: port={{ wildfly_manage_https_port }}/tcp permanent=true immediate=true
state=enabled

- name: Open wildfly management https udp port
firewalld: port={{ wildfly_manage_https_port }}/udp permanent=true immediate=true
state=enabled

- name: Open wildfly http tcp port
Expand All @@ -43,6 +51,14 @@
firewalld: port={{ wildfly_http_port }}/udp permanent=true immediate=true
state=enabled

- name: Open wildfly https tcp port
firewalld: port={{ wildfly_https_port }}/tcp permanent=true immediate=true
state=enabled

- name: Open wildfly https udp port
firewalld: port={{ wildfly_https_port }}/udp permanent=true immediate=true
state=enabled

- name: Enable and start the service
service: name=wildfly enabled=yes state=started

Expand Down
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
- include: install.yml
- include: configure.yml
- include: users.yml

- include: ssl.yml
when: wildfly_enable_ssl
47 changes: 47 additions & 0 deletions tasks/ssl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# task file for wildfly

# See the README file on how to generate this file.
- name: Copy keystore file to the configuration folder
copy: src={{ wildfly_keystore_name }}
dest={{ wildfly_keystore_path }}
owner={{ wildfly_user }} group={{ wildfly_group }} mode=0750
notify:
- restart wildfly
- change standalone data mode

- name: Add SSL identity to the management realm
lineinfile:
dest: "{{ wildfly_standalone_config_path }}"
insertafter: <security-realm name="ManagementRealm">
line: "{{ wildfly_application_ssl_identity }}"
owner: "{{ wildfly_user }}"
group: "{{ wildfly_group }}"
mode: 0750
notify:
- restart wildfly
- change standalone data mode

- name: Add https listener for applications
lineinfile:
dest: "{{ wildfly_standalone_config_path }}"
insertafter: <http-listener name=*
line: "{{ wildfly_https_listener }}"
owner: "{{ wildfly_user }}"
group: "{{ wildfly_group }}"
mode: 0750
notify:
- restart wildfly
- change standalone data mode

- name: Add https socket binding to management interfaces
lineinfile:
dest: "{{ wildfly_standalone_config_path }}"
insertafter: <http-interface security-realm="ManagementRealm"*
line: <socket-binding https="management-https"/>
owner: "{{ wildfly_user }}"
group: "{{ wildfly_group }}"
mode: 0750
notify:
- restart wildfly
- change standalone data mode
6 changes: 2 additions & 4 deletions tasks/users.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
# tasks file for wildfly

# This status will always be "changed" unless skipped because it will update
# if exists even with the same credentials.
# The user will always be overwritten every time a user and password is given.
- name: Create management user
command: >
{{ wildfly_dir }}/bin/add-user.sh
{{ wildfly_management_user }} {{ wildfly_management_password }}
become_user: "{{ wildfly_user }}"
when: wildfly_management_user is defined and
wildfly_management_password is defined and
wildfly_management_user_overwrite
wildfly_management_password is defined
4 changes: 4 additions & 0 deletions templates/wildfly.properties.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# System properties for wildfly
jboss.bind.address={{ wildfly_bind_address }}
jboss.management.http.port={{ wildfly_manage_http_port }}
jboss.management.https.port={{ wildfly_manage_https_port }}
jboss.http.port={{ wildfly_http_port }}
jboss.https.port={{ wildfly_https_port }}
jboss.bind.address.management={{ wildfly_management_bind_address }}
jboss.server.temp.dir=/tmp/wildfly

0 comments on commit c071902

Please sign in to comment.