ansible-role-visual-studio-code-extensions icon indicating copy to clipboard operation
ansible-role-visual-studio-code-extensions copied to clipboard

Deal properly with rc/stderr/stdout, linter fixes

Open C0rn3j opened this issue 1 year ago • 1 comments

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"
    ]
}

C0rn3j avatar Feb 08 '24 22:02 C0rn3j

@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.

C0rn3j avatar Mar 19 '24 09:03 C0rn3j