Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
generate tomcat-users.xml as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Darashenka committed Aug 18, 2017
1 parent 8b5e2a1 commit 393c44e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ instance. The following variables are legit to configure per instance.
* ``service_file``: Init system configuration file per instance, e.g. tomcat.conf for Upstart (string, default: ``{{ tomcat_default_service_file }}`` (see ``vars/service/*.yml``))
* ``service_name``: Init system service name per instance, e.g. [email protected] for Systemd (string, default: ``{{ tomcat_default_service_name }}`` (see ``vars/service/*.yml``))
* ``umask``: Allow to configure umask for Tomcat instance (oct, default: ``|default('')``)
* ``systemd_default_instance``: Allow to configure default instance for Systemd templated service (string, default: ``None`` }}
* ``systemd_default_instance``: Allow to configure default instance for Systemd templated service (string, default: ``None``
* ``auth_roles``: which roles should be created in tomcat-users.xml (list of strings, default: [])
* ``auth_users``: which users should be created in tomcat-users.xml (list of auth_users, see below. default: [])

### auth_users

Users to be configured in tomcat_users.xml

* ``name``: username
* ``password``: password in plaintext
* ``roles``: which roles should be configured

Configuring more than one instance requires to configure some of the
variables documented above per instance. Please see example playbooks
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ tomcat_default_user_system: false
# Tomcat configuration
# Default template for configuration file server.xml
tomcat_default_server_xml_template: server.xml.j2
# Default template for configuration file tomcat-users.xml
tomcat_default_tomcatusers_xml_template: tomcat-users.xml.j2
# Default template for configuration file web.xml
tomcat_default_web_xml_template: web.xml.j2
# Default shutdown port (per instance name: item.port_shutdown)
Expand Down
11 changes: 11 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@
args:
creates: "{{ item.0.path|default(tomcat_default_instance_path) }}/conf/{{ item.1 }}"

- name: Install instance tomcat-users.xml
tags: tomcat
become: true
with_items: "{{ tomcat_instances }}"
register: tomcat_registered_install_tomcatusers_xml
template:
src: "{{ item.tomcatusers_xml_template|default(tomcat_default_tomcatusers_xml_template) }}"
dest: "{{ item.path|default(tomcat_default_instance_path) }}/conf/tomcat-users.xml"
owner: "{{ item.user|default(tomcat_default_user_name) }}"
group: "{{ item.group|default(tomcat_default_user_group) }}"
mode: 0640

- name: Install instance server.xml
tags: tomcat
Expand Down
9 changes: 9 additions & 0 deletions templates/tomcat-users.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
{% for role in item.auth_roles|default([]) %}
<role rolename="{{role}}"/>
{% endfor %}
{% for user in item.auth_users|default([]) %}
<user username="{{ user.name }}" password="{{ user.password }}" roles="{{ user.roles }}"/>
{% endfor %}
</tomcat-users>

0 comments on commit 393c44e

Please sign in to comment.