Skip to content

Commit

Permalink
prefer json data over stdout when parsing with cli
Browse files Browse the repository at this point in the history
If the parser argument is provided to the cli module, the output from
the cli command is parsed by the parser.  The cli module will attempt to
convert any output from the cli command from json.  This change will
prefer the json_data over the output for the cli command if the
json_data value is not none.
  • Loading branch information
Peter Sprygada committed Mar 25, 2018
1 parent e51cd76 commit baaa94a
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions action_plugins/cli.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# (c) 2015, Michael DeHaan <[email protected]>
#
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible 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.
# (c) 2018, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

#
import json

from ansible import constants as C
Expand Down Expand Up @@ -70,7 +57,7 @@ def run(self, tmp=None, task_vars=None):
new_task = self._task.copy()
new_task.args = {
'file': parser,
'contents': output
'contents': (json_data or output)
}

kwargs = {
Expand Down

0 comments on commit baaa94a

Please sign in to comment.