Skip to content

Commit

Permalink
Merge pull request #45 from idealista/develop
Browse files Browse the repository at this point in the history
release 1.6.0
  • Loading branch information
sorobon authored Feb 14, 2018
2 parents 3db2626 + bb9e06d commit 96387ba
Show file tree
Hide file tree
Showing 31 changed files with 548 additions and 121 deletions.
4 changes: 4 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
extends: default

ignore: |
*.travis.yml
test_*.yml

rules:
braces:
max-spaces-inside: 1
Expand Down
11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,43 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

## [Unreleased](https://github.com/idealista/tomcat-role/tree/develop)

## [1.6.0](https://github.com/idealista/tomcat-role/tree/1.6.0)
### Added
- *[#43](https://github.com/idealista/tomcat-role/issues/43) Allow to change log files directory* @sorobon

## [1.5.0](https://github.com/idealista/tomcat-role/tree/1.5.0)
### Added
- *[#40](https://github.com/idealista/tomcat-role/issues/40) Support for addons like java-agents* @sorobon

## [1.4.0](https://github.com/idealista/tomcat-role/tree/1.4.0)

### Added
- *[#29](https://github.com/idealista/tomcat-role/issues/29) Upgrade molecule* @jdvr
- *[#26](https://github.com/idealista/tomcat-role/issues/26) Fix to copy extra configuration recursively* @dortegau
- *[#24](https://github.com/idealista/tomcat-role/issues/24) Follow OWASP recommendations to protect Shutdown port* @dortegau
- *[#21](https://github.com/idealista/tomcat-role/issues/21) Remove pre-installed folders from webapps* @dortegau

## [1.3.1](https://github.com/idealista/tomcat-role/tree/1.3.1)

### Fixed
- *[#17](https://github.com/idealista/tomcat-role/issues/17) Fix war user and group after download* @jdvr

## [1.3.0](https://github.com/idealista/tomcat-role/tree/1.3.0)

### Added
- *[#13](https://github.com/idealista/tomcat-role/issues/13) Add maven repository as a valid download war source* @jdvr

## [1.2.0](https://github.com/idealista/tomcat-role/tree/1.2.0)

### Added
- *[#5](https://github.com/idealista/tomcat-role/issues/5) Add a name for the downloaded war during deployment* @jdvr

## [1.1.2](https://github.com/idealista/tomcat-role/tree/1.1.2)

### Fixed
- *[#8](https://github.com/idealista/tomcat-role/issues/8) Fix systemd startup* @jmonterrubio
- *[#6](https://github.com/idealista/tomcat-role/issues/6) Fix conf directory template copy* @jnogol

## [1.1.0](https://github.com/idealista/tomcat-role/tree/1.1.0)

### Added
- *[#1](https://github.com/idealista/tomcat-role/issues/1) Add deploy task* @jdvr


## [1.0.0](https://github.com/idealista/tomcat-role/tree/1.0.0)

### Added
- *First release*
13 changes: 13 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ tomcat_pre_installed_folders_deployed:
deployed: true
host-manager:
deployed: true
ROOT:
deployed: true

## Logs path (optional, by default its used tomcat_default_log_catalina_out, tomcat_default_log_logging_path and tomcat_default_log_valves)
# tomcat_logs_path: /var/log/tomcat
tomcat_logs_level: {
juli: FINE,
catalina: INFO
}

tomcat_default_log_catalina_out: '"$CATALINA_BASE"/logs'
tomcat_default_log_logging_path: "${catalina.base}/logs"
tomcat_default_log_valves: "logs"

## Agent configuration (optional)

Expand Down
3 changes: 2 additions & 1 deletion molecule/agent/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ scenario:
name: agent
verifier:
name: goss
enabled: True
lint:
name: 'None'
name: flake8
1 change: 1 addition & 0 deletions molecule/agent/tests/dumpall.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ vars | to_nice_yaml }}
50 changes: 50 additions & 0 deletions molecule/agent/tests/test_agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---

http:
http://localhost:{{ .Vars.tomcat_http_connector_port }}:
status: 200
{{ range $key := index .Vars.tomcat_agents_config }}
{{ $key.download_url }}:
status: 200
{{ end }}

service:
tomcat:
enabled: true
running: true

user:
{{ .Vars.tomcat_user }}:
exists: true
groups:
- {{ .Vars.tomcat_group }}

group:
{{ .Vars.tomcat_group }}:
exists: true

{{ $user := .Vars.tomcat_user }}
{{ $group := .Vars.tomcat_group }}
{{ $install_path := .Vars.tomcat_install_path }}
port:
tcp:{{ .Vars.tomcat_http_connector_port }}:
listening: true
file:
{{ range $key := index .Vars.tomcat_agents_config }}
{{ $install_path }}:
filetype: directory
exists: true
owner: {{ $user }}
group: {{ $group }}
{{ range $file := index $key.configuration_files}}
{{ $install_path }}/{{ $key.name }}/{{ $file }}:
exists: true
{{ end }}
{{ range $option := index $key.catalina_opts}}
{{ $install_path }}/bin/setagentenv.sh:
exists: true
contains:
- {{ $option }}
{{ end }}

{{ end }}
52 changes: 0 additions & 52 deletions molecule/agent/tests/test_tomcat.yml.j2

This file was deleted.

22 changes: 17 additions & 5 deletions molecule/agent/verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,39 @@
- ../../vars/main.yml
- "{{ playbook_dir }}/group_vars/tomcat/main.yml"


tasks:
- name: Download and install Goss
- name: Download and install goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
mode: 0755

- name: Copy Goss tests to remote
template:
- name: Copy tests to remote
copy:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ playbook_dir }}/tests/test_*.yml"

- name: Copy vars in json to template
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/vars.yml.j2"
with_fileglob:
- "{{ playbook_dir }}/tests/dumpall.j2"
delegate_to: localhost

- name: Copy vars in json to remote
template:
src: "{{ goss_test_directory }}/vars.yml.j2"
dest: "{{ goss_test_directory }}/vars.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "goss -g {{ item }} validate --format {{ goss_format }}"
command: "goss -g {{ item }} --vars {{ goss_test_directory }}/vars.yml validate --format {{ goss_format }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true
Expand Down
9 changes: 9 additions & 0 deletions molecule/change-log-path/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Molecule managed

FROM {{ item.image }}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
16 changes: 16 additions & 0 deletions molecule/change-log-path/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*******
Install
*******

Requirements
============

* Docker Engine
* docker-py

Install
=======

.. code-block:: bash
$ sudo pip install docker-py
60 changes: 60 additions & 0 deletions molecule/change-log-path/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
tasks:
- name: Create Dockerfiles from image names
template:
src: "{{ molecule_scenario_directory }}/Dockerfile.j2"
dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}"
with_items: "{{ molecule_yml.platforms }}"
register: platforms

- name: Discover local Docker images
docker_image_facts:
name: "molecule_local/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images

- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
name: "molecule_local/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(true) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0

- name: Create molecule instance(s)
docker_container:
name: "{{ item.name }}"
hostname: "{{ item.name }}"
image: "molecule_local/{{ item.image }}"
state: started
recreate: false
log_driver: json-file
command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
privileged: "{{ item.privileged | default(omit) }}"
volumes: "{{ item.volumes | default(omit) }}"
capabilities: "{{ item.capabilities | default(omit) }}"
ports: "{{ item.exposed_ports | default(omit) }}"
ulimits: "{{ item.ulimits | default(omit) }}"
register: server
with_items: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0

- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: docker_jobs
until: docker_jobs.finished
retries: 300
with_items: "{{ server.results }}"
27 changes: 27 additions & 0 deletions molecule/change-log-path/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
tasks:
- name: Destroy molecule instance(s)
docker_container:
name: "{{ item.name }}"
state: absent
force_kill: "{{ item.force_kill | default(true) }}"
register: server
with_items: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0

- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: docker_jobs
until: docker_jobs.finished
retries: 300
with_items: "{{ server.results }}"
6 changes: 6 additions & 0 deletions molecule/change-log-path/group_vars/tomcat/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

## JAVA
java_implementation: openjdk

tomcat_logs_path: /var/log/tomcat
30 changes: 30 additions & 0 deletions molecule/change-log-path/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint

platforms:
- name: tomcat
groups:
- tomcat
image: idealista/java-role:latest
privileged: True
capabilities:
- SYS_ADMIN
volumes:
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
command: '/lib/systemd/systemd'

provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: change-log-path
verifier:
name: goss
lint:
name: flake8
Loading

0 comments on commit 96387ba

Please sign in to comment.