Clean up debug-ansible role
Copy in the openstack info, generalize it, and get it to stop spamming stdout. We'll use a python module to do this so that we can control what's going on. Change-Id: Iec3bcec75f28451284c3c7d94593bfca3830bc8b
This commit is contained in:
parent
242f0bfff4
commit
8b86f76ffd
|
@ -6,10 +6,14 @@
|
|||
gather_subset:
|
||||
- "!all"
|
||||
roles:
|
||||
- debug-ansible
|
||||
- role: debug-ansible
|
||||
# TODO(mordred) When we have site-local variables, these should go there
|
||||
zuul_traceroute_host: git.openstack.org
|
||||
zuul_image_manifest: /etc/dib-builddate.txt
|
||||
- role: bindep
|
||||
bindep_profile: test
|
||||
bindep_dir: "{{ zuul_work_dir }}"
|
||||
# TODO(mordred) When we have site-local variables, these should go there
|
||||
bindep_command: /usr/bindep-env/bin/bindep
|
||||
bindep_fallback: /usr/local/jenkins/common_data/bindep-fallback.txt
|
||||
- test-setup
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (c) 2017 Red Hat
|
||||
#
|
||||
# This module is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
|
||||
command_map = {
|
||||
'uname': 'uname -a',
|
||||
'network_interfaces': 'ip address show',
|
||||
'network_routing_v4': 'ip route show',
|
||||
'network_routing_v6': 'ip -6 route show',
|
||||
'network_neighbors': 'ip neighbor show',
|
||||
}
|
||||
|
||||
|
||||
def run_command(command):
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = '{path}:/sbin'.format(path=env['PATH'])
|
||||
return subprocess.check_output(
|
||||
shlex.split(command),
|
||||
stderr=subprocess.STDOUT,
|
||||
env=env)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
image_manifest=dict(required=False, type='str'),
|
||||
traceroute_host=dict(required=False, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
image_manifest = module.params['image_manifest']
|
||||
traceroute_host = module.params['traceroute_host']
|
||||
ret = {'image_manifest': None, 'traceroute': None}
|
||||
|
||||
if image_manifest and os.path.exists(image_manifest):
|
||||
ret['image_manifest'] = open(image_manifest, 'r').read()
|
||||
if traceroute_host:
|
||||
try:
|
||||
ret['traceroute'] = run_command(
|
||||
'traceroute6 -n {host}'.format(host=traceroute_host))
|
||||
except subprocess.CalledProcessError:
|
||||
try:
|
||||
ret['traceroute'] = run_command(
|
||||
'traceroute -n {host}'.format(host=traceroute_host))
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
for key, command in command_map.items():
|
||||
try:
|
||||
ret[key] = run_command(command)
|
||||
except subprocess.CalledProcessError:
|
||||
# TODO(mordred) Make some of these fail so that we get the equiv
|
||||
# of "does this host work"
|
||||
pass
|
||||
|
||||
module.exit_json(changed=False, _zuul_nolog_return=True, **ret)
|
||||
|
||||
from ansible.module_utils.basic import * # noqa
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,5 +1,17 @@
|
|||
- name: Write out all ansible variables/facts known for the host
|
||||
- name: Write out all ansible variables/facts known for each host
|
||||
delegate_to: localhost
|
||||
template:
|
||||
dest: "{{ zuul.executor.log_root }}/ansible-hostvars.{{ inventory_hostname }}.yaml"
|
||||
src: templates/ansible-hostvars.j2
|
||||
|
||||
- name: Collect information about zuul worker
|
||||
zuul_debug_info:
|
||||
image_manifest: "{{ zuul_image_manifest|default(omit) }}"
|
||||
traceroute_host: "{{ zuul_traceroute_host|default(omit) }}"
|
||||
register: zdi
|
||||
|
||||
- name: Write out all zuul information for each host
|
||||
delegate_to: localhost
|
||||
template:
|
||||
dest: "{{ zuul.executor.log_root }}/zuul-info.{{ inventory_hostname }}.txt"
|
||||
src: templates/zuul-info.j2
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
{% if 'image_manifest' in zdi %}
|
||||
Image Information
|
||||
=================
|
||||
{{ zdi.image_manifest }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'uname' in zdi %}
|
||||
Host & kernel
|
||||
=============
|
||||
{{ zdi.uname }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'network_interfaces' in zdi %}
|
||||
Network interface addresses
|
||||
===========================
|
||||
{{ zdi.network_interfaces }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'network_routing_v4' in zdi %}
|
||||
Network routing tables v4
|
||||
=========================
|
||||
{{ zdi.network_routing_v4 }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'network_routing_v6' in zdi %}
|
||||
Network routing tables v6
|
||||
=========================
|
||||
{{ zdi.network_routing_v6 }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'network_neighbors' in zdi %}
|
||||
Network neighbors
|
||||
=================
|
||||
{{ zdi.network_neighbors }}
|
||||
{% endif %}
|
||||
|
||||
{% if 'traceroute' in zdi %}
|
||||
Route to Known Host
|
||||
===================
|
||||
Known Host: {{ zuul_traceroute_host }}
|
||||
{{ zdi.traceroute }}
|
||||
{% endif %}
|
Loading…
Reference in New Issue