GithubHelp home page GithubHelp logo

Comments (8)

mkobel avatar mkobel commented on July 17, 2024 1

@jaredledvina Thank you for your effort! But I already migrated to sensu/sensu-go-ansible. Therefore I no longer have a setup available for testing your changes.

from sensu-go-ansible.

jaredledvina avatar jaredledvina commented on July 17, 2024

Ah fuuuuun, yeah I only have pipenv setup with python 2.7 but considering that's nearly entirely dead I should start testing and getting Python 3 support.

from sensu-go-ansible.

jaredledvina avatar jaredledvina commented on July 17, 2024

Hey @mkobel,

So I started #158 to kick off all of the tests using Python 2.7 and Python 3.7 across all of the supported operating systems

Sadly, it's not reproducing your error here.

Any chance you're able to share the task you used to get this error? I have an idea on the fix but, would like to have a repro to ensure it works correctly.

from sensu-go-ansible.

mkobel avatar mkobel commented on July 17, 2024

The modules fails with the following code in the playbook:

- hosts: sensu_go
  become: yes
  roles:
    - role: jaredledvina.sensu_go_ansible
      sensu_go_manage_community_repo: false
  tasks:
    - name: Create a new check
      sensu_go_check:
        state: present
        host: "{{ sensu_api_host }}"
        port: "{{ sensu_api_port }}"
        username: "{{ sensu_api_user }}"
        password: "{{ sensu_api_password }}"
        namespace: "{{ sensu_namespace }}"
        name: check_example
        interval: 60
        command: 'echo true'
        subscriptions:
          - 'entity:sensu-go'

The system is running Debian 9.9 with ansible_python_interpreter=/usr/bin/python3 in the hosts file.

The exception on the first run is the following:

TASK [Create a new check] **************************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Expecting value: line 1 column 1 (char 0)
fatal: [sensu-go]: FAILED! => {"changed": false, "msg": "Failed to parse response as JSON: {'date': 'Thu, 08 Aug 2019 19:41:14 GMT', 'msg': 'OK (0 bytes)', 'cookies_string': '', 'url': 'http://sensu-go:8080/api/core/v2/namespaces/default/checks', 'sensu-entity-count': '0', 'cookies': {}, 'connection': 'close', 'content-length': '0', 'sensu-entity-limit': '1000', 'content-type': 'application/json', 'status': 201}", "response": ""}

The verbose second execution has the following output (after the first execution another error appears):

TASK [Create a new check] **************************************************************************************************************************************************************************************************************
task path: /home/moritz/git/ansible-moosseedorf/library/install-sensu-go.yml:7
<sensu-go> ESTABLISH LXD CONNECTION FOR USER: root
<sensu-go> EXEC /bin/sh -c 'echo ~root && sleep 0'
<sensu-go> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197 `" && echo ansible-tmp-1565293710.9939227-275568987754197="` echo /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197 `" ) && sleep 0'
Using module file /home/moritz/git/ansible-moosseedorf/roles/jaredledvina.sensu_go_ansible/library/sensu_go_check.py
<sensu-go> PUT /home/moritz/.ansible/tmp/ansible-local-23029xqmet_i8/tmpdal_frn1 TO /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py
<sensu-go> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/ /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py && sleep 0'
<sensu-go> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py && sleep 0'
<sensu-go> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py", line 114, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/usr/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 626, in _exec
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py", line 408, in <module>
  File "/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py", line 404, in main
  File "/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py", line 366, in run_module
RuntimeError: dictionary changed size during iteration

fatal: [sensu-go]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1565293710.9939227-275568987754197/AnsiballZ_sensu_go_check.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/usr/lib/python3.5/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n  File \"/usr/lib/python3.5/imp.py\", line 170, in load_source\n    module = _exec(spec, sys.modules[name])\n  File \"<frozen importlib._bootstrap>\", line 626, in _exec\n  File \"<frozen importlib._bootstrap_external>\", line 673, in exec_module\n  File \"<frozen importlib._bootstrap>\", line 222, in _call_with_frames_removed\n  File \"/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py\", line 408, in <module>\n  File \"/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py\", line 404, in main\n  File \"/tmp/ansible_sensu_go_check_payload_8h9xgw2r/__main__.py\", line 366, in run_module\nRuntimeError: dictionary changed size during iteration\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Does this help? A special case of my setup might be the use of LXD to connect to the system.

from sensu-go-ansible.

mkobel avatar mkobel commented on July 17, 2024

I just recreated the system to run the playbook on the first run verbose:

TASK [Create a new check] *****************************************************************************************
task path: /home/moritz/git/ansible-moosseedorf/library/install-sensu-go.yml:7
<sensu-go> ESTABLISH LXD CONNECTION FOR USER: root
<sensu-go> EXEC /bin/sh -c 'echo ~root && sleep 0'
<sensu-go> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231 `" && echo ansible-tmp-1565294372.1683538-170944937013231="` echo /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231 `" ) && sleep 0'
Using module file /home/moritz/git/ansible-moosseedorf/roles/jaredledvina.sensu_go_ansible/library/sensu_go_check.py
<sensu-go> PUT /home/moritz/.ansible/tmp/ansible-local-30657k8col3l1/tmpmol5gpjn TO /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231/AnsiballZ_sensu_go_check.py
<sensu-go> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231/ /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231/AnsiballZ_sensu_go_check.py && sleep 0'
<sensu-go> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231/AnsiballZ_sensu_go_check.py && sleep 0'
<sensu-go> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1565294372.1683538-170944937013231/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Expecting value: line 1 column 1 (char 0)
fatal: [sensu-go]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "check_hooks": null,
            "command": "echo true",
            "cron": null,
            "env_vars": null,
            "handlers": [],
            "high_flap_threshold": 0,
            "host": "sensu-go",
            "interval": 60,
            "low_flap_threshold": 0,
            "metadata": null,
            "name": "check_example",
            "namespace": "default",
            "output_metric_format": "",
            "output_metric_handlers": null,
            "port": 8080,
            "protocol": "http",
            "proxy_entity_name": "",
            "proxy_requests": null,
            "publish": true,
            "round_robin": false,
            "runtime_assets": null,
            "state": "present",
            "stdin": false,
            "subdue": null,
            "subscriptions": [
                "entity:sensu-go"
            ],
            "timeout": 0,
            "ttl": 0,
            "validate_certs": true
        }
    },
    "msg": "Failed to parse response as JSON: {'msg': 'OK (0 bytes)', 'content-type': 'application/json', 'status': 201, 'connection': 'close', 'content-length': '0', 'date': 'Thu, 08 Aug 2019 19:59:32 GMT', 'cookies_string': '', 'cookies': {}, 'url': 'http://sensu-go:8080/api/core/v2/namespaces/default/checks', 'sensu-entity-count': '0', 'sensu-entity-limit': '1000'}",
    "response": ""
}

from sensu-go-ansible.

jaredledvina avatar jaredledvina commented on July 17, 2024

Ah ha, yes it does, I think I know what the issue is, I'll see if I can get a fix in. Thanks!

from sensu-go-ansible.

jaredledvina avatar jaredledvina commented on July 17, 2024

Not sure where I actually left off with this. Probably in some of the terrible Python code I wrote.

@mkobel if you are bored and want to try to fix this, go for it. I'll also mention that Sensu Inc. hired a team to create https://github.com/sensu/sensu-go-ansible which will be officially supported by them (whereas this is just something I did in my free time). They have a bunch of modules and such which might just be a better alternative to the mess I made haha

from sensu-go-ansible.

jaredledvina avatar jaredledvina commented on July 17, 2024

Should be good to go now, https://github.com/jaredledvina/sensu-go-ansible/releases/tag/3.0.0

from sensu-go-ansible.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.