Skip to content

Commit

Permalink
Merge pull request #42 from idealista/develop
Browse files Browse the repository at this point in the history
release 1.5.0
  • Loading branch information
sorobon authored Feb 1, 2018
2 parents 9447381 + 78b57da commit 3db2626
Show file tree
Hide file tree
Showing 23 changed files with 720 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
- pip install ansible==${ansible_version}
- pip install -r test-requirements.txt
script:
- molecule test
- molecule test --all

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
6 changes: 1 addition & 5 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
extends: default

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

rules:
braces:
max-spaces-inside: 1
Expand All @@ -14,4 +10,4 @@ rules:
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
truthy: disable
# truthy: disable
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

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

## [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
Expand Down
20 changes: 19 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tomcat_ajp_connector_port: 8009
tomcat_connector_redirect_port: 8443

## CATALINA_OPTS
catalina_opts:
tomcat_catalina_opts:
- -Xms512m
- -Xmx512m

Expand Down Expand Up @@ -78,3 +78,21 @@ tomcat_pre_installed_folders_deployed:
deployed: true
host-manager:
deployed: true

## Agent configuration (optional)

# tomcat_agents_required_libs:
# - unzip
# - apt-transport-https

# tomcat_agents_config:
# - name: "agent_name"
# download_url: "download_url"
# catalina_opts:
# - '-javaagent:{{ tomcat_install_path }}/agent_name/agent_file'
# configuration_files:
# - "configuration_file.yml"
# params: {
# application_name: "application_name",
# license_key: "license_key"
# }
9 changes: 9 additions & 0 deletions molecule/agent/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/agent/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/agent/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/agent/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 }}"
20 changes: 20 additions & 0 deletions molecule/agent/group_vars/tomcat/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

## JAVA
java_implementation: openjdk

tomcat_agents_required_libs:
- unzip
- apt-transport-https

tomcat_agents_config:
- name: "newrelic"
download_url: "http://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip"
catalina_opts:
- '-javaagent:{{ tomcat_install_path }}/newrelic/newrelic.jar'
configuration_files:
- "newrelic.yml"
params: {
application_name: "application_sample_name",
license_key: "sddsasd"
}
30 changes: 30 additions & 0 deletions molecule/agent/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: agent
verifier:
name: goss
lint:
name: 'None'
13 changes: 13 additions & 0 deletions molecule/agent/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: Tomcat | Installing required dependencies
apt:
pkg: "{{ item }}"
state: present
with_items:
- net-tools
roles:
- java
- tomcat-role
5 changes: 5 additions & 0 deletions molecule/agent/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks: []
5 changes: 5 additions & 0 deletions molecule/agent/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- src: idealista.java-role
version: 2.0.1
name: java
Loading

0 comments on commit 3db2626

Please sign in to comment.