-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnova-trace-logs.yml
207 lines (176 loc) · 8.28 KB
/
nova-trace-logs.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Playbook to inspect logs for Nova instance activities
# Usage: Boot an instance (or have the UUID of a previously booted instance)
# ansible-playbook nova-trace-logs.yml -i hosts -e nova_instance=<uuid>
# View output at results/nova-trace-sorted-<uuid>.log
#
# To skip the debug flag check:
# ansible-playbook nova-trace-logs.yml -i hosts -e nova_instance=<uuid> -e force_debug_logs=false
# NOTE: You won't see full details of the instance without debug logs on. But you have the option to check first without enabling them...
- hosts: controller
name: Controller Checks
remote_user: "{{ remote_user }}"
become: "{{ become }}"
vars:
# If debug isn't enabled you won't get a full view of instance boot actions
force_debug_logs: true
roles:
- common
tasks:
- name: Get Debug Settings
shell: openstack-config --get {{ item }} DEFAULT debug
register: openstack_config_debug
changed_when: no
ignore_errors: yes
with_items:
- /etc/nova/nova.conf
- /etc/neutron/neutron.conf
- /etc/neutron/metadata_agent.ini
- /etc/neutron/l3_agent.ini
- /etc/neutron/dhcp_agent.ini
- /etc/glance/glance-api.conf
- /etc/glance/glance-registry.conf
- /etc/cinder/cinder.conf
- /etc/keystone/keystone.conf
- name: Fail if debug set to false
fail: msg="Debug set to false in {{ item.item }} on {{ ansible_hostname }}"
when: "(force_debug_logs == true) and ({{ item.rc }} != 0 or '{{ item.stdout }}' == 'False' or '{{ item.stdout }}' == 'false')"
changed_when: no
with_items: "{{ openstack_config_debug.results }}"
- name: Fail if nova_instance not set
fail: msg="You must set a nova_instance variable to execute this playbook"
when: "nova_instance is undefined"
changed_when: no
- name: Get Instance Logs
shell: grep {{ nova_instance }} {{ item }}
register: instance_logs
changed_when: no
ignore_errors: yes
with_items:
- /var/log/nova/nova-api.log
- /var/log/nova/nova-conductor.log
- /var/log/nova/nova-consoleauth.log
- /var/log/nova/nova-manage.log
- /var/log/nova/nova-novncproxy.log
- /var/log/nova/nova-scheduler.log
- /var/log/neutron/dhcp-agent.log
- /var/log/neutron/l3-agent.log
- /var/log/neutron/metadata-agent.log
- /var/log/neutron/openvswitch-agent.log
- /var/log/neutron/server.log
- /var/log/glance/api.log
- /var/log/glance/registry.log
- /var/log/cinder/api.log
- /var/log/cinder/cinder-manage.log
- /var/log/cinder/scheduler.log
- /var/log/cinder/volume.log
- /var/log/keystone/keystone.log
- name: Get openstack server details
shell: openstack --os-username={{os_admin_username}} --os-password={{os_admin_password}} --os-project-name={{os_admin_project_name}} --os-auth-url={{os_auth_url}} server show {{ nova_instance }}
register: openstack_server_show
changed_when: no
ignore_errors: yes
- name: Get openstack server faults
shell: openstack --os-username={{os_admin_username}} --os-password={{os_admin_password}} --os-project-name={{os_admin_project_name}} --os-auth-url={{os_auth_url}} server show {{ nova_instance }} -c fault -f value
register: openstack_server_show_fault
changed_when: no
ignore_errors: yes
- name: Set nova_instance_fault fact if the instance has a fault
set_fact:
nova_instance_fault: "{{ openstack_server_show_fault.stdout }}"
when: "{{ 'openstack_server_show_fault.stdout' }} != ''"
changed_when: no
ignore_errors: yes
- name: Get Hypervisor Disabled/down List
#shell: nova --os-user-name {{os_admin_username}} --os-password {{os_admin_password}} --os-project-name {{os_admin_project_name}} --os-auth-url {{os_auth_url}} hypervisor-list | tr '+-' '#' | egrep -v '####|Hypervisor|up|enabled'
shell: nova --os-user-name {{os_admin_username}} --os-password {{os_admin_password}} --os-project-name {{os_admin_project_name}} --os-auth-url {{os_auth_url}} hypervisor-list
register: hypervisor_down
changed_when: no
ignore_errors: yes
#### Do something with this if hypervisors down or disabled
#- name:
#openstack hypervisor show 1 -c hypervisor_hostname -c status -c state -c free_ram_mb -c running_vms -c vcpus -c vcpus_used -f value | sed ':a;N;$!ba;s/\n/,/g'
#
- hosts: compute
name: Compute Checks
remote_user: "{{ remote_user }}"
become: "{{ become }}"
vars:
# If debug isn't enabled you won't get a full view of instance boot actions
force_debug_logs: true
roles:
- common
tasks:
# TODO - Make more efficient by checking only the target hypervisor vs. all
- name: Get Debug Settings
shell: openstack-config --get {{ item }} DEFAULT debug
register: openstack_config_debug
changed_when: no
ignore_errors: yes
with_items:
- /etc/nova/nova.conf
- /etc/neutron/neutron.conf
- name: Fail if debug set to false
fail: msg="Debug set to false in {{ item.item }} on {{ ansible_hostname }}"
when: "(force_debug_logs == true) and ({{ item.rc }} != 0 or '{{ item.stdout }}' == 'False' or '{{ item.stdout }}' == 'false')"
changed_when: no
with_items: "{{ openstack_config_debug.results }}"
- name: Get Instance Logs
shell: grep {{ nova_instance }} {{ item }}
register: instance_logs
changed_when: no
ignore_errors: yes
with_items:
- /var/log/nova/nova-compute.log
- /var/log/neutron/openvswitch-agent.log
# TODO- Add instance console log check as well?
- hosts: localhost
#gather_facts: True # Needed for date/time in report
become: false
name: Generating config report
vars:
- debug: false
tags:
- report
tasks:
- name: Dump host vars
debug: var=hostvars[item]
with_items: "{{groups['all']}}"
when: debug == true
- local_action: template src=templates/nova-trace-logs.j2 dest={{result_dir}}/nova-trace-{{nova_instance}}.log
become: false
- name: Sort nova instance trace output
shell: sort -k1 {{result_dir}}/nova-trace-{{nova_instance}}.log > {{result_dir}}/nova-trace-sorted-{{nova_instance}}.log
- name: Faults | Check for no valid host
shell: grep Filter {{result_dir}}/nova-trace-sorted-{{nova_instance}}.log
register: fault_no_valid_host
changed_when: no
ignore_errors: yes
when: "(hostvars[groups['controller'][0]].nova_instance_fault is defined) and ('No valid host was found' in '{{ hostvars[groups['controller'][0]].nova_instance_fault.message }}')"
- debug:
var: fault_no_valid_host
verbosity: 1
- name: Set fact for host filter log
set_fact:
host_filter_log: "{{fault_no_valid_host.stdout_lines.1.split(\"', '\")}}"
when: "(hostvars[groups['controller'][0]].nova_instance_fault is defined) and ('No valid host was found' in '{{ hostvars[groups['controller'][0]].nova_instance_fault.message }}')"
- debug:
var: host_filter_log
verbosity: 1
- name: Set fact for failed filter
set_fact:
failed_filter: "{{fault_no_valid_host.stdout_lines.1.split(\"Filter results: \").1.split(\"', '\")[-1].split(\":\")[0]}}"
#failed_filter: {{fault_no_valid_host.stdout_lines.1.split("Filter results{{':'}} ").1.split("', '")[-1].split(":")[0]}}
when: "(hostvars[groups['controller'][0]].nova_instance_fault is defined) and ('No valid host was found' in '{{ hostvars[groups['controller'][0]].nova_instance_fault.message }}')"
- debug:
var: failed_filter
verbosity: 1
###- debug: var=fault_no_valid_host.stdout_lines
#- debug: var=fault_no_valid_host.stdout_lines.1.split("', '")
###- debug: var=fault_no_valid_host.stdout_lines.1.split("Filter results{{':'}} ").1.split("', '")
###- debug: var=fault_no_valid_host.stdout_lines.1.split("Filter results{{':'}} ").1.split("', '")[-1]
#- debug: var=fault_no_valid_host.stdout_lines.1.split("Filter results{{':'}} ").1.split("', '")[-1].split(":")[0]
### If RetryFilter, do this...
### If RamFilter, do this...
### If CoreFilter, do this...
- local_action: template src=templates/nova-trace-analyze.j2 dest={{result_dir}}/nova-trace-analyze-{{nova_instance}}.log
become: false