forked from HaaikeV/ansible-jboss-windows-counter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eap.yml
59 lines (49 loc) · 1.59 KB
/
eap.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
- name: EAP
hosts: eap
gather_facts: true
vars:
jboss_process:
jboss_installed: "false"
fuse_installed: "false"
jboss_version: "none"
# windows_servers: "groups['eap']" #### for J2 Template
tasks:
- block:
- name: Get JAVA processes for Fuse and JBOSS search
win_shell: Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | Select-Object -ExpandProperty CommandLine
register: java_process
- name: Get JBOSS processes
win_shell: Get-Process -Name jboss* | Select path
register: jboss_process
- name: Check for fuse
set_fact:
fuse_installed: yes
when: java_process.stdout.find('fuse') != -1
- name: Check for jboss
set_fact:
jboss_installed: yes
when: java_process.stdout.find('jboss') != -1
- name: Find JBOSS version
set_fact:
jboss_version: "{{ java_process.stdout | regex_search('(?i)[j J]boss-eap-\\d+\\.\\d+|wildfly') }}"
when: java_process.stdout.find('jboss') != -1
- name: Create file header
lineinfile:
dest: /tmp/eap
line: "Hostname,Fuse Installed,Jboss Installed,Version"
create: true
delegate_to: localhost
run_once: true
# - name: Build Output
# lineinfile:
# dest: /tmp/eap
# line: "{{ansible_hostname}}, {{fuse_installed}}, {{jboss_installed}}, {{jboss_version}} "
# delegate_to: localhost
# when: ansible_os_family == "Windows"
- name: Build the report
template:
src: csv.j2
dest: /tmp/eap_csv
delegate_to: localhost
run_once: True