0

We would like to execute a package comparer to compare Chocolatey packages from the local repository with the public repository. Now when we execute the playbook, the copy of the script goes well but the execution of the script goes good too but then fails for some reason. Maybe one of you could help me with this?

 tasks:
    - name: Copy powershell file to Chocolatey server
      win_copy:
        src: ../powershell/package_comparer.ps1
        dest: C:\Temp\

    - name: Executing Powershell script
      win_shell: C:\Temp\package_comparer.ps1
      changed_when: false
      register: result

    - name: parse .json file
      set_fact:
         packages_result: "{{(result.stdout | from_json)}}"

    - debug:
        msg: "{{ packages_results }}"

That we can execute this without error.. As I get now this error:

[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin (<ansible.plugins.callback.yaml.CallbackModule object at 0x7fecd4ee8910>): value must be a string

Callback Exception:
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 333, in send_callback
    method(*new_args, **kwargs)
   File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/default.py", line 93, in v2_runner_on_failed
    self._display.display("fatal: [%s]: FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result)),
   File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/yaml.py", line 123, in _dump_results
    dumped += to_text(yaml.dump(abridged_result, allow_unicode=True, width=1000, Dumper=AnsibleDumper, default_flow_style=False))
   File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 293, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
   File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 281, in dump_all
    dumper.represent(data)
   File "/usr/lib64/python2.7/site-packages/yaml/representer.py", line 30, in represent
    self.serialize(node)
   File "_yaml.pyx", line 1348, in _yaml.CEmitter.serialize (ext/_yaml.c:15963)
   File "_yaml.pyx", line 1510, in _yaml.CEmitter._serialize_node (ext/_yaml.c:18037)
   File "_yaml.pyx", line 1431, in _yaml.CEmitter._serialize_node (ext/_yaml.c:17021)


PLAY RECAP **********************************************************************************************************************************************************************************************
host_machine        : ok=1    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
Zeitounator
  • 38,476
  • 7
  • 53
  • 66
  • We cannot see from your output which task is failing. Is it the `set_fact` task ? Can you show the content of `result.stdout` ? Please edit your question to add this information. – Zeitounator Nov 05 '19 at 10:56
  • Check if it is failing at debug level.. because you stored variable to "packages_result" but at debug command you are trying to call "packages_results".. if it's not the case, provide info like Zeitounator asked in comments. – Sai Nov 05 '19 at 15:18
  • @Zeitounator That is the point, I cannot see the result.stdout as it fails there... –  Nov 06 '19 at 07:37
  • @Sai Fixed it, thanks for the headsup but still got the error :( –  Nov 06 '19 at 07:38

0 Answers0