Skip to content

Commit

Permalink
File date role issues and improve logging for role failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevan Holdaway committed Feb 12, 2018
1 parent daed8cd commit c09231c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 98 deletions.
94 changes: 0 additions & 94 deletions foo.json

This file was deleted.

7 changes: 6 additions & 1 deletion quipucords/scanner/network/inspect_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def normalize_result(result):
return [(key, value)
for key, value in result._result[ANSIBLE_FACTS].items()
if not key.startswith(INTERNAL_)]
# return list(result._result[ANSIBLE_FACTS].items())
elif (isinstance(result._task.register, str) and
not result._task.register.startswith(INTERNAL_)):
return [(result._task.register, result._result)]
Expand Down Expand Up @@ -98,6 +97,12 @@ def v2_runner_on_ok(self, result):

def v2_runner_on_failed(self, result, ignore_errors=False):
"""Print a json representation of the result."""
# pylint: disable=protected-access
with_items = result._result.get('results') is not None
if not with_items and result._result.get('msg') is not None:
self.scan_task.log_message(
'Unexpected ansible error: %s' % result._result,
log_level=logging.ERROR)
self.handle_result(result)

def handle_result(self, result):
Expand Down
8 changes: 5 additions & 3 deletions roles/date/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
when: '"stdout" not in internal_date_anaconda_log_cmd'

- name: gather date.machine_id fact
raw: ls --full-time /etc/machine-id | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
raw: if [ -f /etc/machine-id ] ; then ls --full-time /etc/machine-id 2>/dev/null | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' ; fi
register: date_machine_id
ignore_errors: yes

- name: gather date.filesystem_create fact
raw: fs_date=$(tune2fs -l $(mount | egrep '/ type' | grep -o '/dev.* on' | sed -e 's/\on//g') | grep 'Filesystem created' | sed 's/Filesystem created:\s*//g'); if [[ $fs_date ]]; then date +'%F' -d \"$fs_date\"; else echo "" ; fi
raw: fs_date=$(tune2fs -l $(mount | egrep '/ type' | grep -o '/dev.* on' | sed -e 's/\on//g') | grep 'Filesystem created' | sed 's/Filesystem created:\s*//g'); if [[ $fs_date ]]; then date +'%F' -d "$fs_date"; else echo "" ; fi
register: date_filesystem_create
ignore_errors: yes
when: 'internal_have_tune2fs'
Expand All @@ -46,4 +46,6 @@
- name: extract result value for date.yum_history
set_fact:
date_yum_history: "{{ internal_date_yum_history_cmd['stdout_lines'] | select | first if internal_have_yum else '' }}"
when: '"stdout_lines" in internal_date_yum_history_cmd'
when:
- '"stdout_lines" in internal_date_yum_history_cmd'
- 'internal_date_yum_history_cmd["stdout_lines"]|length > 0'

0 comments on commit c09231c

Please sign in to comment.