naftulikay / ansible-role-degoss

An Ansible role for installing, running, and removing Goss from a system without leaving any traces.
Other
42 stars 12 forks source link

Sanitize Environment Variables #15

Closed naftulikay closed 7 years ago

naftulikay commented 7 years ago

Closes #13.

naftulikay commented 7 years ago

The following diff:

diff --git a/tests/playbook.yml b/tests/playbook.yml
index a124093..8137343 100644
--- a/tests/playbook.yml
+++ b/tests/playbook.yml
@@ -20,3 +20,11 @@
       goss_env_vars:
         distro: "{{ ansible_distribution | lower }}"
         should: "{{ should }}"
+        boolean: true
+        list:
+          - one
+          - two
+          - three
+        dict:
+          a: b
+          c: d

This yields the following helpful error and failure developed in #14:

TASK [degoss : report module errors] ***************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Goss Module Run Failed."}

Traceback (most recent call last):
  File "/tmp/ansible_fIz6iL/ansible_module_goss.py", line 96, in <module>
    main()
  File "/tmp/ansible_fIz6iL/ansible_module_goss.py", line 88, in main
    rc, stdout, stderr = evaluate(module, test_file, fmt, executable, env_vars)
  File "/tmp/ansible_fIz6iL/ansible_module_goss.py", line 52, in evaluate
    environ_update=env_vars
  File "/tmp/ansible_fIz6iL/ansible_modlib.zip/ansible/module_utils/basic.py", line 2328, in run_command
  File "/usr/lib/python2.7/os.py", line 473, in __setitem__
    putenv(key, item)
TypeError: putenv() argument 2 must be string, not dict
naftulikay commented 7 years ago

And this has now been fixed by this PR.