Skip to content

Commit

Permalink
Fit @gaima8 new feature into this role.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdebock committed Jan 9, 2021
1 parent 62303e4 commit e59f87c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
pass_filenames: false

- repo: https://github.com/robertdebock/pre-commit
rev: v1.1.1
rev: v1.1.2
hooks:
- id: ansible_role_find_unused_variable
- id: ansible_role_find_empty_files
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ tomcat_ssl_connector_port: 8443
tomcat_shutdown_port: 8005
tomcat_ajp_port: 8009
tomcat_jre_home: /usr
tomcat_service_state: started
tomcat_service_enabled: yes
# You can bind Tomcat to a specified address globally using this variable, or
# in the `tomcat_instances`. The `tomcat_instances.address` is more specific
# so it takes priority over `tomcat_address`.
Expand Down Expand Up @@ -170,6 +172,8 @@ tomcat_instances:
access_log_prefix: "{{ tomcat_access_log_prefix }}"
access_log_suffix: "{{ tomcat_access_log_suffix }}"
access_log_pattern: "{{ tomcat_access_log_pattern }}"
service_state: "{{ tomcat_service_state }}"
service_enabled: "{{ tomcat_service_enabled }}"

# The explicit version to use when referring to the short name.
tomcat_version7: 7.0.107
Expand Down Expand Up @@ -292,6 +296,7 @@ Apache-2.0
I'd like to thank everybody that made contributions to this repository. It motivates me, improves the code and is just fun to collaborate.
- [brunoleon](https://github.com/brunoleon)
- [gaima8](https://github.com/gaima8)
- [javid90khan](https://github.com/javid90khan)
- [patsevanton](https://github.com/patsevanton)
- [till](https://github.com/till)
Expand Down
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ tomcat_ssl_connector_port: 8443
tomcat_shutdown_port: 8005
tomcat_ajp_port: 8009
tomcat_jre_home: /usr
tomcat_service_state: started
tomcat_service_enabled: yes
# You can bind Tomcat to a specified address globally using this variable, or
# in the `tomcat_instances`. The `tomcat_instances.address` is more specific
# so it takes priority over `tomcat_address`.
Expand Down Expand Up @@ -54,8 +56,8 @@ tomcat_instances:
access_log_prefix: "{{ tomcat_access_log_prefix }}"
access_log_suffix: "{{ tomcat_access_log_suffix }}"
access_log_pattern: "{{ tomcat_access_log_pattern }}"
service_state: started
service_enabled: yes
service_state: "{{ tomcat_service_state }}"
service_enabled: "{{ tomcat_service_enabled }}"

# The explicit version to use when referring to the short name.
tomcat_version7: 7.0.107
Expand Down
36 changes: 36 additions & 0 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@
- tomcat_jre_home is string
quiet: yes

- name: test if tomcat_service_state is set correctly
assert:
that:
- tomcat_service_state is defined
- tomcat_service_state in [ "reloaded", "restarted", "started", "stopped" ]
quiet: yes

- name: test if tomcat_service_enabled is set correctly
assert:
that:
- tomcat_service_enabled is defined
- tomcat_service_enabled is boolean
quiet: yes

- name: test if tomcat_instances is set correctly
assert:
that:
Expand Down Expand Up @@ -341,3 +355,25 @@
label: "{{ item.name }}"
when:
- item.config_files is defined

- name: test if item.service_state in tomcat_instances is set correctly
assert:
that:
- item service_state in [ "reloaded", "restarted", "started", "stopped" ]
quiet: yes
loop: "{{ tomcat_instances }}"
loop_control:
label: "{{ item.name }}"
when:
- item.service_state is defined

- name: test if item.service_enabled in tomcat_instances is set correctly
assert:
that:
- item service_enabled is boolean
quiet: yes
loop: "{{ tomcat_instances }}"
loop_control:
label: "{{ item.name }}"
when:
- item.service_enabled is defined
6 changes: 3 additions & 3 deletions tasks/instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
user_name: "{{ instance.user | default(tomcat_user) }}"
group_name: "{{ instance.group | default(tomcat_group) }}"

- name: set tomcat instance service to {{ instance.service_state | default('started') }} and {{ instance.service_enabled | default('yes') }}
- name: manage tomcat service
service:
name: "{{ instance.name }}"
state: "{{ instance.service_state | default('started') }}"
enabled: "{{ instance.service_enabled | default('yes') }}"
state: "{{ instance.service_state | default(tomcat_service_state) }}"
enabled: "{{ instance.service_enabled | default(tomcat_service_enabled) }}"

- name: loop over wars
include: war.yml
Expand Down

0 comments on commit e59f87c

Please sign in to comment.