Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal properly with rc/stderr/stdout, linter fixes #138

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

C0rn3j
Copy link
Contributor

@C0rn3j C0rn3j commented Feb 8, 2024

Fixes #118

Standardized as per https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html

Now it's actually possible to get stdout/stderr with verbose options.

Now STDERR isn't checked anymore for content, only return codes are taken into account, in every stage.

Before:

failed: [luxuria.rys.pw] (item=c0rn3j: redhxat.ansible) => 
{
  "ansible_loop_var": "item",
  "changed": false,
  "item": [
    {
      "username": "c0rn3j",
      "visual_studio_code_extensions_absent": [
        "zbr.vscode-ansible"
      ]
    },
    "redhxat.ansible"
  ],
  "msg": "Error while installing extension [redhxat.ansible]: (1) Installing extensions...\nWarning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.\nExtension 'redhxat.ansible' not found.\nMake sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp\nFailed Installing Extensions: redhxat.ansible\n"
}

After:

failed: [luxuria.rys.pw] (item=c0rn3j: redhxat.ansible) => 
{
  "ansible_loop_var": "item",
  "changed": false,
  "item": [
    {
      "username": "c0rn3j",
      "visual_studio_code_extensions_absent": [
        "zbr.vscode-ansible"
      ]
    },
    "redhxat.ansible"
  ],
  "msg": "Error while installing extension [redhxat.ansible]",
  "rc": 1,
  "stderr": "Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.\nExtension 'redhxat.ansible' not found.\nMake sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp\nFailed Installing Extensions: redhxat.ansible\n",
  "stderr_lines": [
    "Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.",
    "Extension 'redhxat.ansible' not found.",
    "Make sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp",
    "Failed Installing Extensions: redhxat.ansible"
  ],
  "stdout": "Installing extensions...\n",
  "stdout_lines": [
    "Installing extensions..."
  ]
}

Fuller task:

TASK [gantsign.visual-studio-code-extensions : Uninstall extensions] ******************************************************************************************************************************************************************************************************************************
task path: /root/.ansible/roles/gantsign.visual-studio-code-extensions/tasks/main.yml:33
ok: [luxuria.rys.pw] => (item=c0rn3j: zbr.vscode-ansible) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "executable": "code-oss",
            "name": "zbr.vscode-ansible",
            "state": "absent"
        }
    },
    "item": [
        {
            "username": "c0rn3j",
            "visual_studio_code_extensions": [
                "redhat.ansible",
                "vsciot-vscode.vscode-arduino",
                "ms-vscode.cpptools",
                "hediet.vscode-drawio",
                "eamodio.gitlens",
                "oderwat.indent-rainbow",
                "timonwong.shellcheck",
                "simonsiefke.svg-preview"
            ]
        },
        "zbr.vscode-ansible"
    ],
    "msg": "zbr.vscode-ansible is not installed",
    "stderr": "Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.\n",
    "stderr_lines": [
        "Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium."
    ],
    "stdout": "eamodio.gitlens\ngolang.go\nhediet.vscode-drawio\nmarlinfirmware.auto-build\nms-python.debugpy\nms-python.python\nms-python.vscode-pylance\nms-vscode.cmake-tools\nms-vscode.cpptools\nms-vscode.powershell\nms-vscode.vscode-serial-monitor\noderwat.indent-rainbow\nplatformio.platformio-ide\nredhat.ansible\nredhat.vscode-yaml\nsimonsiefke.svg-preview\ntimonwong.shellcheck\ntwxs.cmake\nvsciot-vscode.vscode-arduino\n",
    "stdout_lines": [
        "eamodio.gitlens",
        "golang.go",
        "hediet.vscode-drawio",
        "marlinfirmware.auto-build",
        "ms-python.debugpy",
        "ms-python.python",
        "ms-python.vscode-pylance",
        "ms-vscode.cmake-tools",
        "ms-vscode.cpptools",
        "ms-vscode.powershell",
        "ms-vscode.vscode-serial-monitor",
        "oderwat.indent-rainbow",
        "platformio.platformio-ide",
        "redhat.ansible",
        "redhat.vscode-yaml",
        "simonsiefke.svg-preview",
        "timonwong.shellcheck",
        "twxs.cmake",
        "vsciot-vscode.vscode-arduino"
    ]
}

… ton of linter errors, switch to f strings for readability, properly return rc+stdout+stderr as is standard
@C0rn3j
Copy link
Contributor Author

C0rn3j commented Mar 19, 2024

@freemanjp I see you cherry picked some of the fixes (thanks!), anything I can do on my side, other than make the code fit on a punch card, to get the rest in?

It's annoying when I accidentally update this extension to stable version and have my Ansible jobs fail because I use Wayland on my systems.

VSC uses old Electron, so there's no way I can force Wayland through an env var, resulting in an omnipresent Wayland flag warning, which this module hard-crashes on in the current state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

code prints to stderr
2 participants