1
+ # https://codeshare.io/X80xJM
2
+ ---
3
+ - hosts : " {{ NODES }}"
4
+ gather_facts : false
5
+
6
+ vars :
7
+ output_file : output.txt
8
+ tasks :
9
+ - name : Create server output file
10
+ file :
11
+ path : " {{ output_file }}"
12
+ state : touch
13
+ owner : root
14
+ group : root
15
+ mode : ' 0644'
16
+ run_once : true
17
+ delegate_to : localhost
18
+
19
+ - name : Server details
20
+ shell : |
21
+ echo "$(uname -n)"
22
+ echo "Old kernel: xyz"
23
+ echo "Current kernel: $(uname -r)"
24
+ # when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
25
+ register : app
26
+
27
+ # - name: check with shell
28
+ # shell: |
29
+ # echo " {{ item }}" >> /opt/depot/dinesh/{{ chg }}-Test.txt
30
+ # loop:
31
+ # - "{{ app.stdout }}"
32
+ # when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
33
+ # delegate_to: localhost
34
+
35
+ - name : Store app server oututs in a file
36
+ # local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
37
+ lineinfile :
38
+ line : " {{ item }}"
39
+ insertafter : EOF
40
+ path : " {{ output_file }}"
41
+ # blockinfile: block=" Hi {{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
42
+ loop :
43
+ - " {{ hostvars[inventory_hostname].app.stdout_lines }}"
44
+ # when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
45
+ # ignore_errors: True
46
+ delegate_to : localhost
47
+ # - debug:
48
+ # msg: "{{ app }}"
49
+ - meta : end_play
50
+ - name : Database server outputs
51
+ shell : |
52
+ echo "************************************************************************************"
53
+ echo "$(uname -n) Output"
54
+ echo "-------------------------------"
55
+ echo "Old kernel: xyz"
56
+ echo "Current kernel: $(uname -r)"
57
+ echo "GRID services status"
58
+ echo "--------------------"
59
+ echo "No GRID setup found on server"
60
+ when : " 'ora' in inventory_hostname"
61
+ register : db
62
+ - name : Postgres Database server outputs
63
+ shell : |
64
+ echo "************************************************************************************"
65
+ echo "$(uname -n) Output"
66
+ echo "-------------------------------"
67
+ echo "Old kernel: xyz"
68
+ echo "Current kernel: $(uname -r)"
69
+ ps -ef | grep /pgsql | grep -v grep > /dev/null
70
+ if [[ $? == 0 ]]; then echo "DB Checkout: Success"; else echo "DB Checkout: Fail"; fi
71
+ echo "-------------------------------"
72
+ when : " 'ql' in inventory_hostname"
73
+ register : pgsql
74
+ - name : Sybase Database server outputs
75
+ shell : |
76
+ echo "************************************************************************************"
77
+ echo "$(uname -n) Output"
78
+ echo "-------------------------------"
79
+ echo "Old kernel: xyz"
80
+ echo "Current kernel: $(uname -r)"
81
+ ps -ef | grep IQ | grep -v grep > /dev/null
82
+ if [[ $? == 0 ]]; then echo "DB Checkout: Success"; else echo "DB Checkout: Fail"; fi
83
+ echo "-------------------------------"
84
+ when : " 'syb' in inventory_hostname"
85
+ register : syb
86
+ # - name: Store app server oututs in a file
87
+ # local_action: lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
88
+ # loop:
89
+ # - "{{ app.stdout | default()}}"
90
+ # when: (not 'ora' in inventory_hostname) and (not 'ql' in inventory_hostname) and (not 'syb' in inventory_hostname)
91
+ # ignore_errors: True
92
+ # - meta: end_play
93
+ - name : Store Oracle database server outputs in a file
94
+ local_action : lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
95
+ loop :
96
+ - " {{ db.stdout | default() }}"
97
+ when : " 'ora' in inventory_hostname"
98
+ ignore_errors : True
99
+ - name : Store Postgres database server outputs in a file
100
+ local_action : lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
101
+ loop :
102
+ - " {{ pgsql.stdout | default() }}"
103
+ when : " 'ql' in inventory_hostname"
104
+ ignore_errors : True
105
+ - name : Store Sybase database server outputs in a file
106
+ local_action : lineinfile line="{{ item }}" insertafter=EOF path=/opt/depot/dinesh/{{ chg }}-Test.txt
107
+ loop :
108
+ - " {{ syb.stdout | default() }}"
109
+ when : " 'syb' in inventory_hostname"
110
+ ignore_errors : True
0 commit comments