├── .gitignore ├── tests ├── syntax-check.yml ├── inventory ├── requirements.yml └── yamllint.yml ├── molecule └── default │ ├── prepare.yml │ ├── playbook.yml │ ├── INSTALL.rst │ ├── tests │ └── test_default.py │ ├── Dockerfile.j2 │ └── molecule.yml ├── meta └── main.yml ├── .travis.yml ├── handlers └── main.yml ├── templates └── jboss-as.conf.j2 ├── defaults └── main.yml ├── README.md ├── tasks ├── apply_patch.yml ├── main.yml └── jboss_instance.yml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | *.pyc 3 | tests/roles/ 4 | -------------------------------------------------------------------------------- /tests/syntax-check.yml: -------------------------------------------------------------------------------- 1 | - hosts: jboss_eap_centos_hosts 2 | gather_facts: false 3 | tasks: 4 | - include_role: 5 | name: "../" -------------------------------------------------------------------------------- /tests/inventory: -------------------------------------------------------------------------------- 1 | localhost ansible_connection=local 2 | 3 | [jboss_eap_centos_hosts] 4 | 127.0.0.1 ansible_ssh_user=vagrant ansible_ssh_port=2200 -------------------------------------------------------------------------------- /tests/requirements.yml: -------------------------------------------------------------------------------- 1 | - src: redhat-cop.jboss-common 2 | name: redhat-cop.jboss_common 3 | 4 | - src: sabre1041.redhat-csp-download 5 | name: sabre1041.redhat-csp-download -------------------------------------------------------------------------------- /molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | tasks: 5 | - name: Install Required Packages for Testing 6 | package: 7 | name: initscripts 8 | state: latest 9 | -------------------------------------------------------------------------------- /molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | tasks: 5 | - name: Common Role 6 | include_role: 7 | name: "redhat-cop.jboss_common" 8 | - name: JBoss EAP Role 9 | include_role: 10 | name: "../../../" 11 | -------------------------------------------------------------------------------- /tests/yamllint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | extends: default 4 | 5 | rules: 6 | line-length: 7 | level: error 8 | max: 250 9 | document-start: 10 | present: true 11 | level: error 12 | comments: 13 | require-starting-space: false 14 | truthy: disable 15 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Red Hat Consulting 4 | description: Role for Red Hat JBoss Enterprise Application Platform (EAP) 5 | company: Red Hat 6 | license: license (Apache) 7 | min_ansible_version: 2.0.2.0 8 | platforms: 9 | - name: EL 10 | versions: 11 | - 7 12 | - 6 13 | galaxy_tags: 14 | - java 15 | - jboss 16 | - eap 17 | dependencies: 18 | - {role: sabre1041.redhat-csp-download} 19 | -------------------------------------------------------------------------------- /molecule/default/INSTALL.rst: -------------------------------------------------------------------------------- 1 | ******* 2 | Docker driver installation guide 3 | ******* 4 | 5 | Requirements 6 | ============ 7 | 8 | * General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) 9 | * Docker Engine 10 | * docker-py 11 | * docker 12 | 13 | Install 14 | ======= 15 | 16 | Ansible < 2.6 17 | 18 | .. code-block:: bash 19 | 20 | $ sudo pip install docker-py 21 | 22 | Ansible >= 2.6 23 | 24 | .. code-block:: bash 25 | 26 | $ sudo pip install docker 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | language: python 4 | python: 5 | - "2.7" 6 | 7 | cache: 8 | directories: 9 | - $HOME/.cache/pip 10 | 11 | env: 12 | global: 13 | - ANSIBLE_HOST_KEY_CHECKING=False 14 | - PIP_DOWNLOAD_CACHE=$HOME/.cache/pip 15 | 16 | before_install: 17 | - sudo apt-get update -qq 18 | 19 | install: 20 | - pip install -U pip 21 | - pip install ansible==2.6 "ansible-lint<4.0" yamllint flake8 molecule docker "pytest<3.10" 22 | 23 | # command to run tests 24 | script: 25 | - | 26 | if $TRAVIS_SECURE_ENV_VARS; then 27 | molecule test 28 | else 29 | molecule dependency 30 | molecule lint 31 | molecule syntax 32 | fi 33 | -------------------------------------------------------------------------------- /molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | import pytest 5 | 6 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 7 | os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') 8 | 9 | 10 | @pytest.mark.parametrize('pkg', [ 11 | 'unzip', 12 | 'java-1.8.0-openjdk-devel', 13 | 'python2-pip' 14 | ]) 15 | def test_pkg(host, pkg): 16 | package = host.package(pkg) 17 | 18 | assert package.is_installed 19 | 20 | 21 | @pytest.mark.parametrize('service', [ 22 | 'jboss-standalone', 23 | ]) 24 | def test_systemd(host, service): 25 | systemd_service = host.service(service) 26 | 27 | assert systemd_service.is_enabled 28 | assert systemd_service.is_running 29 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | ## 4 | # As the EAP service would be named like jboss-as-standlone.sh or jboss-eap.sh 5 | # the service ( directed via systemctl ) requires the service name to be without 6 | # extension hence we use spiltext filter to get the service name wihout '.sh' extension 7 | ## 8 | - name: Restart JBoss 9 | become: true 10 | service: 11 | name: "{{ jboss_eap_service_file }}" 12 | state: restarted 13 | 14 | # Sanity test if everything was setup right and JBoss is running 15 | - name: Verify JBoss is running 16 | wait_for: port="{{ instance_calculated_http_port }}" host="{{ instance_bind_address }}" timeout=120 17 | notify: Check JBoss is available 18 | 19 | - name: Check JBoss is available 20 | uri: 21 | url: "http://{{ instance_bind_address }}:{{ instance_bind_address }}" 22 | -------------------------------------------------------------------------------- /templates/jboss-as.conf.j2: -------------------------------------------------------------------------------- 1 | ## 2 | # {{ansible_managed}} 3 | ## 4 | ## Process user 5 | JBOSS_USER={{jboss_eap_user}} 6 | ## Waiting time for returning control to SHELL, it depends upon how many applications/services that will be deployed 7 | STARTUP_WAIT=120 8 | ## Waiting time for returning control to SHELL, it depends upon how many applications/services that will be undeployed 9 | SHUTDOWN_WAIT=30 10 | ## Log directory and file. 11 | JBOSS_CONSOLE_LOG={{ jboss_eap_service_log_dir }}/jboss-{{ instance_name }}/console.log 12 | ## JBoss EAP home directory 13 | JBOSS_HOME={{jboss_eap_home}} 14 | ## JBoss EAP Config 15 | JBOSS_CONFIG={{instance_config}} 16 | ## JBoss Mode ( will be ignored by EAP6 init.d scripts) and only used by EAP7 init scripts 17 | JBOSS_MODE={{instance_mode}} 18 | JBOSS_PIDFILE={{ jboss_eap_pid_file }} -------------------------------------------------------------------------------- /molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | 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; \ 10 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ 11 | 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; \ 12 | elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ 13 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 14 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi 15 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | options: 5 | role-file: tests/requirements.yml 6 | force: true 7 | driver: 8 | name: docker 9 | lint: 10 | name: yamllint 11 | options: 12 | config-file: tests/yamllint.yml 13 | platforms: 14 | - name: centos-systemd 15 | image: centos/systemd:latest 16 | privileged: True 17 | port_bindings: 18 | - 8080:8080 19 | published_ports: 20 | - 0.0.0.0:8080:8080/TCP 21 | command: "/usr/sbin/init" 22 | provisioner: 23 | name: ansible 24 | lint: 25 | name: ansible-lint 26 | options: 27 | x: 28 | - 301 29 | - 305 30 | - 204 31 | inventory: 32 | group_vars: 33 | all: 34 | transfer_method: csp-to-host 35 | rhn_username: ${RHN_USERNAME} 36 | rhn_password: ${RHN_PASSWORD} 37 | scenario: 38 | name: default 39 | test_sequence: 40 | - dependency 41 | - lint 42 | - destroy 43 | - dependency 44 | - syntax 45 | - create 46 | - prepare 47 | - converge 48 | # - idempotence 49 | - side_effect 50 | - verify 51 | - destroy 52 | verifier: 53 | name: testinfra 54 | lint: 55 | name: flake8 56 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | jboss_eap_artifact_source: https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=55301 3 | jboss_eap_patch_artifact_source: https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=57891 4 | jboss_eap_artifacts_dl_dest_dir: /tmp 5 | jboss_eap_group: jboss_as 6 | jboss_eap_user: jboss-as 7 | jboss_eap_library_dest_dir: "/opt/{{ jboss_eap_user }}" 8 | jboss_eap_base_version: 7.1 9 | jboss_eap_home_dir_name: jboss-eap-{{jboss_eap_base_version}} 10 | jboss_eap_base_directory_name: jboss-eap-7.1.0 11 | jboss_eap_artifact_name: "{{ jboss_eap_base_directory_name }}.zip" 12 | jboss_eap_patch_artifact_name: jboss-eap-7.1.2-patch.zip 13 | jboss_eap_standalone_backup_dir_name: .standalone 14 | 15 | jboss_eap_default_logging_timezone: America/New_York 16 | jboss_eap_default_config: standalone.xml 17 | jboss_eap_default_mode: standalone 18 | jboss_eap_bind_default_web_address: 0.0.0.0 19 | jboss_eap_bind_default_management_address: 0.0.0.0 20 | jboss_eap_default_http_port: 8080 21 | jboss_eap_default_management_port: 9990 22 | 23 | # TODO: Reenable patch 24 | jboss_eap_apply_patch: true 25 | 26 | jboss_eap_service_conf_dir: "/etc/jboss" 27 | jboss_eap_service_log_dir: "/var/log" 28 | jboss_eap_service_data_dir: "/var/run" 29 | 30 | jboss_instances: 31 | - name: standalone 32 | 33 | 34 | # ussually this is set at the playbook level 35 | #transfer_method: # csp-to-host | copy-from-contoller | url 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED - This repository is no longer maintained 2 | 3 | **Capabilities provided by this repository have migrated to the [ansible-middleware](https://github.com/ansible-middleware) project and specifically the [wildfly](https://github.com/ansible-middleware/wildfly) repository.** 4 | 5 | Ansible JBoss EAP Role [![Build Status](https://travis-ci.org/redhat-cop/jboss_eap.svg)](https://travis-ci.org/redhat-cop/jboss_eap) 6 | ================= 7 | 8 | A role to install JBoss Enterprise Application Platform on RHEL7. Intended to be used with [JBoss Middleware Playbooks](https://github.com/redhat-cop/ansible-middleware-playbooks) 9 | 10 | Transfer Method 11 | ------------ 12 | 13 | This role supports a few different mechanism for transferring the product zip files to the target host. These are documented on [the main playbooks README](https://github.com/redhat-cop/ansible-middleware-playbooks), as the methods are supported across a variety of roles. 14 | 15 | Dependencies 16 | ------------ 17 | 18 | - java 19 | - unzip 20 | 21 | Our playbooks provide these dependencies in a [common role](https://github.com/redhat-cop/ansible-role-jboss-common), but this there is no explicitly ansible dependency to allow end users more options. 22 | 23 | JBoss Instance Customization 24 | ---------------- 25 | 26 | JBoss instances can be customized on a per host/group basis by modifying the `jboss_instance` property. By default, a single standalone instance is deployed with HTTP and Management interfaces exposed to all interfaces. 27 | 28 | ``` 29 | jboss_instances: 30 | - name: standalone 31 | ``` 32 | 33 | There are several ways in which you can customize the JBoss instances as described below. 34 | 35 | - Create a single instance called _standalone_ which does not publicly expose the Management interface 36 | 37 | ``` 38 | jboss_instances: 39 | - name: standalone 40 | bind_management_address: 127.0.0.1 41 | ``` 42 | 43 | - Create multiple instances on the same machine with a port offset of 100 44 | 45 | ``` 46 | jboss_instances: 47 | - name: node1 48 | - name: node2 49 | port_offset: 100 50 | ``` 51 | 52 | Example Playbooks 53 | ---------------- 54 | 55 | - [JBoss EAP 7.1 on RHEL 7](https://github.com/redhat-cop/ansible-middleware-playbooks/blob/master/eap7.1-rhel7.yml) 56 | 57 | License 58 | ------- 59 | 60 | [LICENSE](./LICENSE) 61 | 62 | Authors Information 63 | ------------------ 64 | 65 | - [Andrew Block](https://github.com/sabre1041) 66 | - [Albert Wong](https://github.com/alberttwong) 67 | - [Justin Holmes](https://github.com/sherl0cks) 68 | - [Kamesh Sampath](https://github.com/kameshsampath) 69 | -------------------------------------------------------------------------------- /tasks/apply_patch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Set JBoss EAP Patch Download Facts 4 | set_fact: 5 | jboss_eap_patch_artifact_url: "{{ jboss_eap_patch_artifact_source }}" 6 | jboss_eap_patch_dest: "{{ jboss_eap_artifacts_dl_dest_dir }}/{{ jboss_eap_patch_artifact_name }}" 7 | 8 | 9 | # Currently we only support patching from base (e.g. 6.x.0), not incremental minor release patches as the role is for initial install 10 | - name: Determine if the Patch Can Be Applied 11 | become_user: "{{ jboss_eap_user }}" 12 | become: yes 13 | command: "{{ jboss_eap_home }}/bin/jboss-cli.sh 'patch info --verbose'" 14 | register: patch_info_result 15 | when: not jboss_eap_exists.stat.exists | bool 16 | 17 | 18 | #### Download and install base library and patch 19 | 20 | - name: Async Download JBoss EAP Patch by URL (HTTP/HTTPS/FTP) 21 | get_url: 22 | url: "{{ jboss_eap_patch_artifact_url }}" 23 | dest: "{{ jboss_eap_patch_dest }}" 24 | url_username: "{{ url_username | default(None) }}" 25 | url_password: "{{ url_password | default(None) }}" 26 | async: 7200 27 | poll: 0 28 | register: url_jboss_eap_patch_download 29 | tags: 30 | - jboss_eap 31 | when: transfer_method == 'url' and (not jboss_eap_exists.stat.exists | bool or patch_info_result is defined) 32 | 33 | - name: Check On JBoss EAP Patch Download Completion (URL) 34 | async_status: jid={{ url_jboss_eap_patch_download.ansible_job_id }} 35 | register: job_result2 36 | until: job_result2.finished 37 | retries: 600 38 | delay: 10 39 | tags: 40 | - jboss_eap 41 | when: transfer_method == 'url' and (not jboss_eap_exists.stat.exists | bool or patch_info_result is defined) 42 | 43 | - name: Async Download JBoss EAP Patch from Red Hat Customer Portal 44 | redhat_csp_download: 45 | url: "{{ jboss_eap_patch_artifact_url }}" 46 | dest: "{{ jboss_eap_patch_dest }}" 47 | username: "{{ rhn_username }}" 48 | password: "{{ rhn_password }}" 49 | async: 7200 50 | poll: 0 51 | register: csp_jboss_eap_patch_download 52 | tags: 53 | - jboss_eap 54 | when: 55 | - transfer_method == 'csp-to-host' and jboss_eap_apply_patch | bool and (not jboss_eap_exists.stat.exists | bool or (patch_info_result is defined and patch_info_result is defined)) 56 | 57 | - name: Check On JBoss EAP Patch Download Completion (CSP) 58 | async_status: jid={{ csp_jboss_eap_patch_download.ansible_job_id }} 59 | register: job_result2 60 | until: job_result2.finished 61 | retries: 600 62 | delay: 10 63 | tags: 64 | - jboss_eap 65 | when: transfer_method == 'csp-to-host' and (not jboss_eap_exists.stat.exists | bool or patch_info_result is defined) 66 | 67 | - name: Copy JBoss EAP Patch 68 | copy: 69 | src: "{{ jboss_eap_patch_artifact_name }}" 70 | dest: "{{ jboss_eap_patch_dest }}" 71 | when: transfer_method == 'copy-from-controller' and (not jboss_eap_exists.stat.exists | bool or patch_info_result is defined) 72 | 73 | - name: Determine current JBoss EAP patch info 74 | become_user: "{{ jboss_eap_user }}" 75 | become: yes 76 | command: "{{ jboss_eap_home }}/bin/jboss-cli.sh {{ '--command=' ~ cmd | quote }}" 77 | vars: 78 | cmd: >- 79 | patch info 80 | register: patch_info 81 | 82 | - name: Set Cumulative Patch ID 83 | set_fact: 84 | jboss_eap_cumulative_patch_id: "{{ patch_info.stdout | regex_replace('(?s).*Cumulative patch ID: *(\\S+).*', '\\1') }}" 85 | 86 | - name: Determine available patch ID 87 | become_user: "{{ jboss_eap_user }}" 88 | become: yes 89 | command: "{{ jboss_eap_home }}/bin/jboss-cli.sh {{ '--command=' ~ cmd | quote }}" 90 | vars: 91 | cmd: >- 92 | patch inspect {{ jboss_eap_patch_dest }} 93 | register: patch_inspect 94 | 95 | - name: Set fact jboss_eap_patch_id 96 | set_fact: 97 | jboss_eap_patch_id: "{{ patch_inspect.stdout | regex_replace('(?s).*Patch ID: *(\\S+).*', '\\1') }}" 98 | 99 | # Patches can be applied while EAP is running 100 | - name: Apply JBoss EAP Patch 101 | become_user: "{{ jboss_eap_user }}" 102 | become: yes 103 | command: "{{ jboss_eap_home }}/bin/jboss-cli.sh {{ '--command=' ~ cmd | quote }}" 104 | vars: 105 | cmd: >- 106 | patch apply /tmp/{{ jboss_eap_patch_artifact_name }} --verbose --override-all 107 | when: >- 108 | jboss_eap_cumulative_patch_id != jboss_eap_patch_id 109 | #notify: 110 | # - Restart jboss-as Service 111 | # - Verify jboss-as is running 112 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Fail for Missing Transfer Method 4 | fail: 5 | msg: "This role requires transfer_method to be set and non empty. See the README" 6 | when: transfer_method is not defined or transfer_method | length == 0 7 | 8 | - name: Fail for Missing Red Hat Network Username 9 | fail: 10 | msg: This role requires rhn_username to be set and non empty." 11 | when: transfer_method == 'csp-to-host' and (rhn_username is not defined or rhn_username | length == 0) 12 | 13 | - name: Fail for Missing Red Hat Network Password 14 | fail: 15 | msg: "This role requires rhn_password to be set and non empty." 16 | when: transfer_method == 'csp-to-host' and (rhn_password is not defined or rhn_password | length == 0) 17 | 18 | - name: Set JBoss EAP Download Facts 19 | set_fact: 20 | jboss_eap_artifact_url: "{{ jboss_eap_artifact_source }}" 21 | jboss_eap_artifact_dl_dest: "{{ jboss_eap_artifacts_dl_dest_dir }}/{{ jboss_eap_artifact_name }}" 22 | 23 | - name: Set JBoss EAP Service Directories Facts 24 | set_fact: 25 | jboss_eap_home: "{{ jboss_eap_library_dest_dir }}/{{ jboss_eap_home_dir_name }}" 26 | 27 | - name: Create JBoss EAP Group 28 | group: 29 | name: "{{ jboss_eap_group }}" 30 | system: yes 31 | state: present 32 | gid: "{{ jboss_eap_group_gid | default('400') }}" 33 | 34 | - name: Create JBoss EAP User 35 | user: 36 | name: "{{ jboss_eap_user }}" 37 | comment: "JBoss EAP User" 38 | uid: "{{ jboss_eap_user_uid | default('400') }}" 39 | group: "{{ jboss_eap_group }}" 40 | home: "{{ jboss_eap_library_dest_dir }}" 41 | shell: "/bin/bash" 42 | 43 | 44 | #### Defensive Programming To Check If EAP Is Already Installed 45 | - name: Check Existence of Libraries 46 | become: true 47 | stat: 48 | path: "{{ jboss_eap_library_dest_dir + '/' + jboss_eap_home_dir_name + '/version.txt' }}" 49 | register: jboss_eap_exists 50 | 51 | 52 | - name: Async Download JBoss EAP by URL (HTTP/HTTPS/FTP) 53 | get_url: 54 | url: "{{ jboss_eap_artifact_url }}" 55 | dest: "{{ jboss_eap_artifact_dl_dest }}" 56 | url_username: "{{ url_username | default(None) }}" 57 | url_password: "{{ url_password | default(None) }}" 58 | async: 7200 59 | poll: 0 60 | register: url_jboss_eap_download 61 | when: transfer_method == 'url' and not jboss_eap_exists.stat.exists | bool 62 | 63 | - name: Check On JBoss EAP Download Completion (URL) 64 | async_status: jid={{ url_jboss_eap_download.ansible_job_id }} 65 | register: job_result1 66 | until: job_result1.finished 67 | retries: 600 68 | delay: 10 69 | when: transfer_method == 'url' and not jboss_eap_exists.stat.exists | bool 70 | 71 | - name: Async Download JBoss EAP from Red Hat Customer Portal 72 | redhat_csp_download: 73 | url: "{{ jboss_eap_artifact_url }}" 74 | dest: "{{ jboss_eap_artifact_dl_dest }}" 75 | username: "{{ rhn_username }}" 76 | password: "{{ rhn_password }}" 77 | async: 7200 78 | poll: 0 79 | register: csp_jboss_eap_download 80 | tags: 81 | - jboss_eap 82 | when: transfer_method == 'csp-to-host' and not jboss_eap_exists.stat.exists | bool 83 | 84 | - name: Check On JBoss EAP Download Completion (CSP) 85 | async_status: jid={{ csp_jboss_eap_download.ansible_job_id }} 86 | register: job_result1 87 | until: job_result1.finished 88 | retries: 600 89 | delay: 10 90 | tags: 91 | - jboss_eap 92 | when: transfer_method == 'csp-to-host' and not jboss_eap_exists.stat.exists | bool 93 | 94 | 95 | - name: Copy JBoss EAP 96 | copy: 97 | src: "{{ jboss_eap_artifact_name }}" 98 | dest: "{{ jboss_eap_artifact_dl_dest }}" 99 | when: transfer_method == 'copy-from-controller' and not jboss_eap_exists.stat.exists | bool 100 | 101 | - name: Extract JBoss EAP Libraries 102 | become: true 103 | unarchive: 104 | src: "{{ jboss_eap_artifact_dl_dest }}" 105 | dest: "{{ jboss_eap_library_dest_dir }}" 106 | creates: "{{ jboss_eap_home_dir_name }}" 107 | copy: no 108 | owner: "{{ jboss_eap_user }}" 109 | group: "{{ jboss_eap_group }}" 110 | when: not jboss_eap_exists.stat.exists | bool 111 | 112 | - name: Patch 113 | include_tasks: apply_patch.yml 114 | when: jboss_eap_apply_patch|bool 115 | 116 | - name: Check if Backup Standalone Directory Exists 117 | stat: 118 | path: "{{ jboss_eap_home }}/{{ jboss_eap_standalone_backup_dir_name }}" 119 | register: standalone_backup_dir 120 | 121 | - name: Create Backup Standalone Directory 122 | command: "cp -r {{ jboss_eap_home }}/{{ jboss_eap_default_mode }} {{ jboss_eap_home }}/{{ jboss_eap_standalone_backup_dir_name }}" 123 | when: not standalone_backup_dir.stat.exists 124 | 125 | - name: Change Permissions on Standalone Backup Directory 126 | file: 127 | state: directory 128 | recurse: yes 129 | path: "{{ jboss_eap_home }}/{{ jboss_eap_standalone_backup_dir_name }}" 130 | owner: "{{ jboss_eap_user }}" 131 | group: "{{ jboss_eap_group }}" 132 | 133 | - name: Validate Instance Configuration 134 | fail: 135 | msg: Invalid JBoss instance configuration 136 | when: jboss_instances is undefined or jboss_instances | length == 0 137 | 138 | - name: Configure Instances 139 | include_tasks: jboss_instance.yml 140 | with_items: "{{ jboss_instances }}" 141 | loop_control: 142 | loop_var: instance 143 | -------------------------------------------------------------------------------- /tasks/jboss_instance.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Set Instance facts 4 | set_fact: 5 | instance_name: "{{ instance.name }}" 6 | instance_mode: "{{ instance.mode | default('') if instance.mode is defined else jboss_eap_default_mode }}" 7 | instance_config: "{{ instance.config | default('') if instance.config is defined else jboss_eap_default_config }}" 8 | instance_java_opts: "{{ instance.java_opts | default('') if instance.java_opts is defined else '' }}" 9 | instance_logging_timezone: "{{ instance.logging_timezone | default('') if instance.logging_timezone is defined else jboss_eap_default_logging_timezone }}" 10 | instance_http_port: "{{ instance.http_port | default('') if instance.http_port is defined else jboss_eap_default_http_port }}" 11 | instance_management_port: "{{ instance.management_port | default('') if instance.management_port is defined else jboss_eap_default_management_port }}" 12 | instance_bind_address: "{{ instance.bind_address | default('') if instance.bind_address is defined else jboss_eap_bind_default_web_address }}" 13 | instance_bind_management_address: "{{ instance.bind_management_address | default('') if instance.bind_management_address is defined else jboss_eap_bind_default_management_address }}" 14 | instance_port_offset: "{{ instance.port_offset | default('') if instance.port_offset is defined else '' }}" 15 | instance_node_name: "{{ instance.node_name | default('') if instance.node_name is defined else instance.name }}" 16 | 17 | - name: Calculate Port Values 18 | set_fact: 19 | instance_calculated_http_port: "{{ (instance_http_port|int + instance_port_offset|default('0')|int) }}" 20 | instance_calculated_management_port: "{{ (instance_management_port|int + instance_port_offset|default('0')|int) }}" 21 | 22 | - name: Set JBoss EAP Instance Facts 23 | set_fact: 24 | jboss_eap_runtime_conf_filename: "{{ instance_mode }}-{{ instance_name }}.conf" 25 | jboss_eap_service_file: "jboss-{{ instance_name }}" 26 | jboss_eap_bin_dir: "{{ jboss_eap_home }}/bin" 27 | 28 | - name: Set JBoss EAP Service Files Facts 29 | set_fact: 30 | jboss_eap_service_conf_file: "{{ jboss_eap_service_conf_dir }}/jboss-{{ instance_name }}.conf" 31 | jboss_eap_runtime_conf_src_file: "{{ jboss_eap_bin_dir }}/{{ instance_mode }}.conf" 32 | jboss_eap_runtime_conf_file: "{{ jboss_eap_bin_dir }}/{{ jboss_eap_runtime_conf_filename }}" 33 | jboss_eap_service_src_file: "{{ (jboss_eap_base_version is version('7.0','<')) | ternary('jboss-as-'+instance_mode+'.sh','jboss-eap-rhel.sh') }}" 34 | jboss_eap_initd_service_file: "/etc/init.d/{{ jboss_eap_service_file }}" 35 | jboss_eap_pid_file: "{{ jboss_eap_service_data_dir }}/jboss-{{ instance_name }}/jboss-{{ instance_name }}.pid" 36 | 37 | - name: Check if {{ instance_name }} Directory Exists 38 | stat: 39 | path: "{{ jboss_eap_home }}/{{ instance_name }}" 40 | register: instance_homedir 41 | 42 | - name: Create {{ instance_name }} Directory 43 | command: "cp -r {{ jboss_eap_home }}/{{ jboss_eap_standalone_backup_dir_name }} {{ jboss_eap_home }}/{{ instance_name }}" 44 | when: not instance_homedir.stat.exists 45 | 46 | - name: Change Permissions on {{ instance_name }} Directory 47 | file: 48 | state: directory 49 | recurse: yes 50 | path: "{{ jboss_eap_home }}/{{ instance_name }}" 51 | owner: "{{ jboss_eap_user }}" 52 | group: "{{ jboss_eap_group }}" 53 | 54 | 55 | - name: Create Temporary Working Directory 56 | tempfile: 57 | prefix: "jboss-{{ instance_name }}" 58 | state: directory 59 | register: jboss_instance_mktemp 60 | changed_when: False 61 | 62 | - name: Create JBoss EAP Service Conf Directory 63 | file: 64 | path: "{{ jboss_eap_service_conf_dir }}" 65 | owner: "{{ jboss_eap_user }}" 66 | group: "{{ jboss_eap_group }}" 67 | state: directory 68 | mode: 0755 69 | 70 | - name: Create JBoss EAP Service Log Directory 71 | file: 72 | path: "{{ jboss_eap_service_log_dir }}/{{ instance_name }}" 73 | owner: "{{ jboss_eap_user }}" 74 | group: "{{ jboss_eap_group }}" 75 | state: directory 76 | mode: 0755 77 | 78 | - name: Create JBoss EAP Service Runtime Data Directory 79 | file: 80 | path: "{{ jboss_eap_service_data_dir }}/{{ instance_name }}" 81 | owner: "{{ jboss_eap_user }}" 82 | group: "{{ jboss_eap_group }}" 83 | state: directory 84 | mode: 0755 85 | 86 | - name: Copy JBoss EAP Service Conf File 87 | template: 88 | owner: "{{ jboss_eap_user }}" 89 | group: "{{ jboss_eap_group }}" 90 | src: jboss-as.conf.j2 91 | dest: "{{ jboss_eap_service_conf_file }}" 92 | mode: 0755 93 | 94 | - name: Copy JBoss Service Configuration File to Temp Directory 95 | become: true 96 | copy: 97 | src: "{{ jboss_eap_runtime_conf_src_file }}" 98 | dest: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_runtime_conf_filename }}" 99 | remote_src: True 100 | owner: "{{ jboss_eap_user }}" 101 | group: "{{ jboss_eap_group }}" 102 | 103 | - name: Copy JBoss EAP Service File 104 | become: true 105 | copy: 106 | src: "{{ jboss_eap_bin_dir }}/init.d/{{ jboss_eap_service_src_file }}" 107 | dest: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_service_file }}" 108 | remote_src: True 109 | owner: "{{ jboss_eap_user }}" 110 | group: "{{ jboss_eap_group }}" 111 | mode: 0755 112 | 113 | - name: Modify JBoss EAP Service File 114 | lineinfile: 115 | state: present 116 | path: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_service_file }}" 117 | regexp: "{{ item.regexp }}" 118 | line: "{{ item.line }}" 119 | with_items: 120 | - {regexp: "^# processname:", line: "# processname: jboss-{{ instance_name }}"} 121 | - {regexp: "^# pidfile:", line: "# pidfile: {{ jboss_eap_pid_file }}"} 122 | - {regexp: "^# config:", line: "# config: {{ jboss_eap_service_conf_file }}"} 123 | - {regexp: "JBOSS_CONF=", line: " JBOSS_CONF='{{ jboss_eap_service_conf_file }}'"} 124 | - {regexp: "^ JBOSS_NAME", line: " JBOSS_NAME='jboss-{{ instance_name }}'"} 125 | 126 | - name: Add RUN_CONF to EAP Service File 127 | lineinfile: 128 | state: present 129 | path: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_service_file }}" 130 | line: "RUN_CONF={{ jboss_eap_runtime_conf_file }}" 131 | insertbefore: "^# Source function library." 132 | 133 | - name: Inject RUN_CONF to Startup in EAP Service File 134 | replace: 135 | path: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_service_file }}" 136 | regexp: "LAUNCH_JBOSS_IN_BACKGROUND=1" 137 | replace: "LAUNCH_JBOSS_IN_BACKGROUND=1 RUN_CONF=$RUN_CONF" 138 | 139 | #TODO: Node Name 140 | - name: Set Java Options Facts 141 | set_fact: 142 | instance_java_opts: "{{ (instance_java_opts + ' ' + item) | trim }}" 143 | with_items: 144 | - "{{ '-Djboss.bind.address='+(instance_bind_address | default('')) if (instance_bind_address is defined and instance_bind_address|trim|length != 0) else '' }}" 145 | - "{{ '-Djboss.bind.address.management='+(instance_bind_management_address | default('')) if (instance_bind_management_address is defined and instance_bind_management_address|trim|length != 0) else '' }}" 146 | - "{{ '-Duser.timezone='+(instance_logging_timezone | default('')) if (instance_logging_timezone is defined and instance_logging_timezone|trim|length != 0) else '' }}" 147 | - "{{ '-Djboss.socket.binding.port-offset='+(instance_port_offset | default('')) if (instance_port_offset is defined and instance_port_offset|trim|length != 0) else '' }}" 148 | - "{{ '-Djboss.node.name='+(instance_node_name | default('')) if (instance_node_name is defined and instance_node_name|trim|length != 0) else '' }}" 149 | - "{{ '-Djboss.server.base.dir=' + instance_name }}" 150 | 151 | - name: Set Java Options 152 | lineinfile: 153 | dest: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_runtime_conf_filename }}" 154 | line: "JAVA_OPTS=\"$JAVA_OPTS {{ instance_java_opts }}\"" 155 | 156 | 157 | - name: Copy JBoss Service Configuration File 158 | become: true 159 | copy: 160 | src: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_runtime_conf_filename }}" 161 | dest: "{{ jboss_eap_runtime_conf_file }}" 162 | remote_src: True 163 | owner: "{{ jboss_eap_user }}" 164 | group: "{{ jboss_eap_group }}" 165 | notify: 166 | - Restart JBoss 167 | - Verify JBoss is running 168 | 169 | - name: Copy JBoss EAP Service File 170 | become: true 171 | copy: 172 | src: "{{ jboss_instance_mktemp.path }}/{{ jboss_eap_service_file }}" 173 | dest: "{{ jboss_eap_initd_service_file }}" 174 | remote_src: True 175 | owner: "{{ jboss_eap_user }}" 176 | group: "{{ jboss_eap_group }}" 177 | mode: 0755 178 | notify: 179 | - Restart JBoss 180 | - Verify JBoss is running 181 | 182 | - name: Remove JBoss Instance Temporary Directory 183 | file: 184 | path: "{{ jboss_instance_mktemp.path }}" 185 | state: absent 186 | 187 | # RHEL 6 expects init.d service with extension 188 | ## 189 | - name: Set JBoss EAP Service Name EL 6 190 | set_fact: 191 | jboss_eap_service_name: "{{ jboss_eap_service_file }}" 192 | when: (ansible_distribution_major_version is version('6','<=')) 193 | 194 | ## 195 | # RHEL 7 expects init.d service without extension 196 | ## 197 | - name: Set JBoss EAP Service Name EL 7 198 | set_fact: 199 | jboss_eap_service_name: "{{ jboss_eap_service_file | splitext | first }}" 200 | when: (ansible_distribution_major_version is version('7','>=')) 201 | 202 | - name: "Enable {{ jboss_eap_service_file }} Service" 203 | become: true 204 | service: 205 | name: "{{ jboss_eap_service_file }}" 206 | enabled: yes 207 | 208 | - name: Flush JBoss instance handlers 209 | meta: flush_handlers 210 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------