Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Move jboss find commands to separate playbook and make non-default
Browse files Browse the repository at this point in the history
Two separate steps here:
  - Moving the JBoss find commands to their own playbook
  - Removing the scan facts from the default fact list

This has the result that Rho will not run a scan unless specifically
requested, and also the find commands are visibly separated from the
rest.
  • Loading branch information
Noah Lavine committed Oct 2, 2017
1 parent 7c6d37b commit 1be5f16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
7 changes: 4 additions & 3 deletions rho/utilities.py
Expand Up @@ -113,9 +113,10 @@
'subman.virt.uuid',
'subman.has_facts_file')

JBOSS_FACTS_TUPLE = ('jboss.installed-versions',
'jboss.deploy-dates',
'jboss.running-versions')
JBOSS_FACTS_TUPLE = ('jboss.running-versions',)

JBOSS_SCAN_FACTS_TUPLE = ('jboss.installed-versions',
'jboss.deploy-dates')

BRMS_FACTS_TUPLE = ('jboss.brms.kie-api-ver',
'jboss.brms.drools-core-ver',
Expand Down
1 change: 1 addition & 0 deletions rho_playbook.yml
Expand Up @@ -22,6 +22,7 @@
- virt
- virt_what
- jboss
- jboss-scan
- brms
- fuse

Expand Down
14 changes: 14 additions & 0 deletions roles/jboss-scan/tasks/main.yml
@@ -0,0 +1,14 @@

---
# Scan linux systems for JBoss EAP or Wildfly Installations
- name: Gather jboss.jar-ver
raw: FOUND=""; for jar in `find {{scan_dirs}} -xdev -name 'jboss-modules.jar' 2>/dev/null | grep -v '\.installation/patches'`; do VERSION=$(java -jar ${jar} -version 2> /dev/null | grep version | sed 's/.*version\s//g'); inode=$(stat -c '%i' "${jar}"); fs=$(df -T "${jar}" | grep "/dev" | sed 's/ .*//'); ctime=$(stat ${jar} | grep 'Change' | grep -oP '[1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]'); if [ ! -z "${VERSION}" ]; then if [ ! -z "$FOUND" ]; then FOUND="$FOUND; $VERSION**$ctime"; else FOUND=${VERSION}'**'${ctime}; fi; fi; done; echo ${FOUND}
register: jboss.jar-ver
ignore_errors: yes
when: 'have_java and ("jboss.installed-versions" in facts_to_collect or "jboss.deploy-dates" in facts_to_collect)'

- name: Gather jboss.run-jar-ver
raw: FOUND=""; for jar in `find {{scan_dirs}} -xdev -name 'run.jar' 2>/dev/null`; do VERSION=$(java -jar ${jar} --version 2> /dev/null | grep build | sed 's/.*[CS]V[NS]Tag.//g' | sed 's/\sdate.*//g'); inode=$(stat -c '%i' "${jar}"); fs=$(df -T "${jar}" | tail -1 | sed 's/ .*//'); ctime=$(stat ${jar} | grep 'Change' | grep -oP '[1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]'); if [ ! -z "${VERSION}" ]; then if [ ! -z "$FOUND" ]; then FOUND="$FOUND; $VERSION**${ctime}"; else FOUND=${VERSION}'**'${ctime}; fi; fi; done; echo ${FOUND};
register: jboss.run-jar-ver
ignore_errors: yes
when: 'have_java and ("jboss.installed-versions" in facts_to_collect or "jboss.deploy-dates" in facts_to_collect)'
13 changes: 0 additions & 13 deletions roles/jboss/tasks/main.yml
@@ -1,18 +1,5 @@

---
# Scan linux systems for JBoss EAP or Wildfly Installations
- name: Gather jboss.jar-ver
raw: FOUND=""; for jar in `find {{scan_dirs}} -xdev -name 'jboss-modules.jar' 2>/dev/null | grep -v '\.installation/patches'`; do VERSION=$(java -jar ${jar} -version 2> /dev/null | grep version | sed 's/.*version\s//g'); inode=$(stat -c '%i' "${jar}"); fs=$(df -T "${jar}" | grep "/dev" | sed 's/ .*//'); ctime=$(stat ${jar} | grep 'Change' | grep -oP '[1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]'); if [ ! -z "${VERSION}" ]; then if [ ! -z "$FOUND" ]; then FOUND="$FOUND; $VERSION**$ctime"; else FOUND=${VERSION}'**'${ctime}; fi; fi; done; echo ${FOUND}
register: jboss.jar-ver
ignore_errors: yes
when: 'have_java and ("jboss.installed-versions" in facts_to_collect or "jboss.deploy-dates" in facts_to_collect)'

- name: Gather jboss.run-jar-ver
raw: FOUND=""; for jar in `find {{scan_dirs}} -xdev -name 'run.jar' 2>/dev/null`; do VERSION=$(java -jar ${jar} --version 2> /dev/null | grep build | sed 's/.*[CS]V[NS]Tag.//g' | sed 's/\sdate.*//g'); inode=$(stat -c '%i' "${jar}"); fs=$(df -T "${jar}" | tail -1 | sed 's/ .*//'); ctime=$(stat ${jar} | grep 'Change' | grep -oP '[1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]'); if [ ! -z "${VERSION}" ]; then if [ ! -z "$FOUND" ]; then FOUND="$FOUND; $VERSION**${ctime}"; else FOUND=${VERSION}'**'${ctime}; fi; fi; done; echo ${FOUND};
register: jboss.run-jar-ver
ignore_errors: yes
when: 'have_java and ("jboss.installed-versions" in facts_to_collect or "jboss.deploy-dates" in facts_to_collect)'

- name: Gather jboss.running-versions
raw: for proc_pid in $(find /proc -maxdepth 1 -xdev -name "[0-9]*"); do ls -l ${proc_pid}/fd 2>/dev/null | grep "java"; done | grep -e "/modules/system/layers/base\|/opt/rh/eap" | sed -n "s/.*\->//p" | sed -n 's/\/modules\/system\/layers\/base.*//p;s/.*\(\/opt\/rh\/eap[1-9]\).*/\1/p' | sort -u
register: jboss.running-versions
Expand Down

0 comments on commit 1be5f16

Please sign in to comment.