community.general icon indicating copy to clipboard operation
community.general copied to clipboard

New module: Jenkins node management

Open phyrwork opened this issue 2 years ago • 11 comments

SUMMARY

Add jenkins_node module for managing Jenkins nodes via python-jenkins REST-API package a la the other jenkins_... modules.

Implement basic states of present (create), absent (delete), disabled (offline), enabled (online).

Implement idempotent configuration of

  • Almost fully, top-level node options including environment variables and tool locations
  • Almost fully, SSH launcher options
  • Some JNLP launcher options

After node creation all configuration is done by updating config.xml by the REST API.

All configuration is opt-in - only options specified will be changed on the Jenkins node.

Best effort taken to only issue a configuration change if we believe we have changed a value.

Where options configure plugins e.g. choice of launcher, API is designed to be extensible. See examples - SSH launcher and SSH host key validation. Some advice on how to document parameters beyond the top-level would be appreciated. Best I could figure so far was to show everything in examples.

Tests pending, but all working as intended against local Jenkins instance - submitting for some initial feedback before I get too far into the tests.

ISSUE TYPE
  • New Module/Plugin Pull Request
COMPONENT NAME

jenkins_node

ADDITIONAL INFORMATION

phyrwork avatar Aug 27 '23 23:08 phyrwork

The test extra-docs failed with 4 errors:

plugins/modules/jenkins_node.py:0:0: 1 validation error for ModuleDocSchema
                                     doc -> options -> labels -> type:0:0:
                                       string does not match regex "^(any|bits|bool|bytes|dict|float|int|json|jsonarg|list|path|raw|sid|str|tmppath|pathspec|pathlist)$" (type=value_error.str.regex; pattern=^(any|bits|bool|bytes|dict|float|int|json|jsonarg|list|path|raw|sid|str|tmppath|pathspec|pathlist)$):0:0:
plugins/modules/jenkins_node.py:0:0: Did not return correct DOCUMENTATION

The test botmeta failed with 2 errors:

.github/BOTMETA.yml:0:0: Author phyrwork not mentioned as active or inactive maintainer for plugins/modules/jenkins_node.py (mentioned are: )
.github/BOTMETA.yml:0:0: No (active or inactive) maintainer mentioned for plugins/modules/jenkins_node.py

The test ansible-test sanity --test no-assert [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:634:9: raise AssertionError instead of: assert 
plugins/modules/jenkins_node.py:1016:13: raise AssertionError instead of: assert

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test no-assert [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:634:9: raise AssertionError instead of: assert 
plugins/modules/jenkins_node.py:1016:13: raise AssertionError instead of: assert

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/modules/jenkins_node.py:456:29: ansible-format-automatic-specification: Format string contains automatic field numbering specification

The test ansible-test sanity --test no-assert [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:634:9: raise AssertionError instead of: assert 
plugins/modules/jenkins_node.py:1016:13: raise AssertionError instead of: assert

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test no-assert [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:634:9: raise AssertionError instead of: assert 
plugins/modules/jenkins_node.py:1016:13: raise AssertionError instead of: assert

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: traceback: SyntaxError: invalid syntax

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

plugins/modules/jenkins_node.py:371:18: SyntaxError: **_kwargs,

The test ansible-test sanity --test validate-modules [explain] failed with 28 errors:

plugins/modules/jenkins_node.py:0:0: doc-choices-do-not-match-spec: Argument 'type' in argument_spec found in launcher defines choices as (['ssh', 'jnlp']) but documentation defines choices as ([])
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'args' in argument_spec found in launcher defines default as ({}) but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'mode' in argument_spec defines default as ('normal') but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'labels' in argument_spec specifies elements as str,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'tools' in argument_spec specifies elements as dict,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'mode' in argument_spec uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'type' in argument_spec found in launcher uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'home' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'name' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in launcher is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'labels' in argument_spec defines type as 'list' but documentation defines type as 'list[str]'
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'tools' in argument_spec defines type as 'list' but documentation defines type as 'dict'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.str: extra keys not allowed @ data['argument_spec']['name']['str']. Got 'str'
plugins/modules/jenkins_node.py:0:0: invalid-documentation: DOCUMENTATION.options.labels.type: not a valid value for dictionary value @ data['options']['labels']['type']. Got 'list[str]'
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'launcher' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'tools' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'args' in argument_spec found in launcher defines type as 'dict' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'description' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'home' in argument_spec found in tools defines type as 'path' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'name' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'type' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'args' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'description' is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'home' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'name' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in tools is listed in the argument_spec, but not documented in the module documentation

The test ansible-test sanity --test validate-modules [explain] failed with 27 errors:

plugins/modules/jenkins_node.py:0:0: doc-choices-do-not-match-spec: Argument 'type' in argument_spec found in launcher defines choices as (['ssh', 'jnlp']) but documentation defines choices as ([])
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'mode' in argument_spec defines default as ('normal') but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'labels' in argument_spec specifies elements as str,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'tools' in argument_spec specifies elements as dict,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'mode' in argument_spec uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'type' in argument_spec found in launcher uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'home' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'name' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in launcher is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'labels' in argument_spec defines type as 'list' but documentation defines type as 'list[str]'
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'tools' in argument_spec defines type as 'list' but documentation defines type as 'dict'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.str: extra keys not allowed @ data['argument_spec']['name']['str']. Got 'str'
plugins/modules/jenkins_node.py:0:0: invalid-documentation: DOCUMENTATION.options.labels.type: not a valid value for dictionary value @ data['options']['labels']['type']. Got 'list[str]'
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'launcher' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'tools' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'args' in argument_spec found in launcher defines type as 'dict' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'description' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'home' in argument_spec found in tools defines type as 'path' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'name' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'type' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'args' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'description' is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'home' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'name' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in tools is listed in the argument_spec, but not documented in the module documentation

The test ansible-test sanity --test validate-modules [explain] failed with 28 errors:

plugins/modules/jenkins_node.py:0:0: doc-choices-do-not-match-spec: Argument 'type' in argument_spec found in launcher defines choices as (['ssh', 'jnlp']) but documentation defines choices as ([])
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'args' in argument_spec found in launcher defines default as ({}) but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'mode' in argument_spec defines default as ('normal') but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'labels' in argument_spec specifies elements as str,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'tools' in argument_spec specifies elements as dict,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'mode' in argument_spec uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'type' in argument_spec found in launcher uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'home' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'name' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in launcher is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'labels' in argument_spec defines type as 'list' but documentation defines type as 'list[str]'
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'tools' in argument_spec defines type as 'list' but documentation defines type as 'dict'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.str: extra keys not allowed @ data['argument_spec']['name']['str']. Got 'str'
plugins/modules/jenkins_node.py:0:0: invalid-documentation: DOCUMENTATION.options.labels.type: not a valid value for dictionary value @ data['options']['labels']['type']. Got 'list[str]'
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'launcher' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'tools' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'args' in argument_spec found in launcher defines type as 'dict' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'description' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'home' in argument_spec found in tools defines type as 'path' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'name' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'type' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'args' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'description' is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'home' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'name' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in tools is listed in the argument_spec, but not documented in the module documentation

The test ansible-test sanity --test validate-modules [explain] failed with 27 errors:

plugins/modules/jenkins_node.py:0:0: doc-choices-do-not-match-spec: Argument 'type' in argument_spec found in launcher defines choices as (['ssh', 'jnlp']) but documentation defines choices as ([])
plugins/modules/jenkins_node.py:0:0: doc-default-does-not-match-spec: Argument 'mode' in argument_spec defines default as ('normal') but documentation defines default as (None)
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'labels' in argument_spec specifies elements as str,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-elements-mismatch: Argument 'tools' in argument_spec specifies elements as dict,but elements is not documented
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'mode' in argument_spec uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-missing-type: Argument 'type' in argument_spec found in launcher uses default type ('str') but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'home' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'name' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in launcher is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-required-mismatch: Argument 'type' in argument_spec found in tools is required, but is not documented as being required
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'labels' in argument_spec defines type as 'list' but documentation defines type as 'list[str]'
plugins/modules/jenkins_node.py:0:0: doc-type-does-not-match-spec: Argument 'tools' in argument_spec defines type as 'list' but documentation defines type as 'dict'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.str: extra keys not allowed @ data['argument_spec']['name']['str']. Got 'str'
plugins/modules/jenkins_node.py:0:0: invalid-documentation: DOCUMENTATION.options.labels.type: not a valid value for dictionary value @ data['options']['labels']['type']. Got 'list[str]'
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'launcher' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: missing-suboption-docs: Argument 'tools' in argument_spec has sub-options but documentation does not define it
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'args' in argument_spec found in launcher defines type as 'dict' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'description' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'home' in argument_spec found in tools defines type as 'path' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'name' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: parameter-type-not-in-doc: Argument 'type' in argument_spec found in tools defines type as 'str' but documentation doesn't define type
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'args' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'description' is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'home' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'name' found in tools is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in launcher is listed in the argument_spec, but not documented in the module documentation
plugins/modules/jenkins_node.py:0:0: undocumented-parameter: Argument 'type' found in tools is listed in the argument_spec, but not documented in the module documentation

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/modules/jenkins_node.py:456:29: ansible-format-automatic-specification: Format string contains automatic field numbering specification

click here for bot help

ansibullbot avatar Aug 27 '23 23:08 ansibullbot

Thanks for your contribution! In case you haven't, please check out the section on adding new modules in CONTRIBUTING.md: https://github.com/ansible-collections/community.general/blob/main/CONTRIBUTING.md#creating-new-modules-or-plugins

Some advice on how to document parameters beyond the top-level would be appreciated.

Grep for "suboptions:". You can use it when type=dict or type=list and elements=dict, for example like this: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/nmcli.py#L129-L164

felixfontein avatar Aug 28 '23 04:08 felixfontein

Grep for "suboptions:". You can use it when type=dict or type=list and elements=dict, for example like this: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/nmcli.py#L129-L164

Thanks, that will get me some of the way there.

However some of my options e.g. launcher select and configure Jenkins plugin types with different sets of args.

e.g. from the docs (and then expanded a bit to make the point)

- name: Use known hosts file for host key verification when connecting to a node by SSH
  community.general.jenkins_node:
    name: my-agent
    launcher:
      type: ssh
      args:
        host: my-agent.test
        port: 22
        credentials_id: 0bf9599f-b551-4afe-abae-cde7b14a406c
        host_key_verify:
          type: content
          args:
            algorithm: ssh-rsa
            key: AAAAB3NzaC1yc2EAAAADAQABAAABgQC...

- name: Set Jenkins node to launch by connecting it to the controller
  community.general.jenkins_node:
    name: my-agent
    launcher:
      type: jnlp
      args:
        data_dir: remoting
        work_dir: custom
        disable_work_dir: yes
        assert_work_dir: no
        use_web_socket: no

Internally there are separate ArgumentSpecValidators for each args set, so that at the top-level the args type can just be dict, but of course the types need enumerating and their options documented in full somewhere.

Can you suggest how I could do this?

phyrwork avatar Aug 28 '23 16:08 phyrwork

However some of my options e.g. launcher select and configure Jenkins plugin types with different sets of args.

e.g. from the docs (and then expanded a bit to make the point)

There is no way to properly document this, except by using examples and annotating them with comments.

What one usually does is provide one sub-option for every type, like args_ssh, args_jnlp. Then you can require args_ssh if type=ssh, require args_jnlp if tpye=jnlp, and make args_ssh and args_jnlp mutually exclusive. See for example https://docs.ansible.com/ansible/latest/collections/community/hrobot/boot_module.html#parameters with the various install_* options (there, type is implicitly set by "which install_* option is set?").

felixfontein avatar Aug 29 '23 05:08 felixfontein

Gradually chipping away at the unit tests when I have time...

phyrwork avatar Sep 12 '23 06:09 phyrwork

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:116:19: W291: trailing whitespace
tests/unit/plugins/modules/test_jenkins_node.py:189:5: E303: too many blank lines (2)

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:116:19: W291: trailing whitespace
tests/unit/plugins/modules/test_jenkins_node.py:189:5: E303: too many blank lines (2)

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:116:19: W291: trailing whitespace
tests/unit/plugins/modules/test_jenkins_node.py:189:5: E303: too many blank lines (2)

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

plugins/modules/jenkins_node.py:116:19: W291: trailing whitespace
tests/unit/plugins/modules/test_jenkins_node.py:189:5: E303: too many blank lines (2)

The test ansible-test sanity --test validate-modules [explain] failed with 8 errors:

plugins/modules/jenkins_node.py:0:0: attributes-check-mode: The module does declare support for check mode, but the check_mode attribute's support value is 'none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.0: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][0]. Got 'host_key_verify_none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.1: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][1]. Got 'host_key_verify_known_hosts'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.2: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][2]. Got 'host_key_verify_provided'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.3: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][3]. Got 'host_key_verify_trusted'
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_provided' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_trusted' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh -> host_key_verify_provided

The test ansible-test sanity --test validate-modules [explain] failed with 7 errors:

plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.0: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][0]. Got 'host_key_verify_none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.1: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][1]. Got 'host_key_verify_known_hosts'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.2: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][2]. Got 'host_key_verify_provided'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.3: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][3]. Got 'host_key_verify_trusted'
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_provided' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_trusted' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh -> host_key_verify_provided

The test ansible-test sanity --test validate-modules [explain] failed with 8 errors:

plugins/modules/jenkins_node.py:0:0: attributes-check-mode: The module does declare support for check mode, but the check_mode attribute's support value is 'none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.0: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][0]. Got 'host_key_verify_none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.1: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][1]. Got 'host_key_verify_known_hosts'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.2: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][2]. Got 'host_key_verify_provided'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.3: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][3]. Got 'host_key_verify_trusted'
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_provided' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_trusted' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh -> host_key_verify_provided

The test ansible-test sanity --test validate-modules [explain] failed with 7 errors:

plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.0: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][0]. Got 'host_key_verify_none'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.1: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][1]. Got 'host_key_verify_known_hosts'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.2: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][2]. Got 'host_key_verify_provided'
plugins/modules/jenkins_node.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.launch_ssh.mutually_exclusive.3: expected list @ data['argument_spec']['launch_ssh']['mutually_exclusive'][3]. Got 'host_key_verify_trusted'
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_provided' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'host_key_verify_trusted' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh
plugins/modules/jenkins_node.py:0:0: no-log-needed: Argument 'key' in argument_spec could be a secret, though doesn't have `no_log` set found in launch_ssh -> host_key_verify_provided

click here for bot help

ansibullbot avatar Sep 12 '23 06:09 ansibullbot

Ping @phyrwork

needs_info

felixfontein avatar Dec 03 '23 08:12 felixfontein

@phyrwork This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

ansibullbot avatar Jan 04 '24 09:01 ansibullbot

Hey. I haven't been able to work on this for some time now and am unlikely to again for a while.

What is missing is unit test coverage for several of the fields implemented - these are tedious to implement and have taken a long time.

I could cut these fields from the PR to be finished later and tidy up what is done... unless it would be acceptable to submit with less than complete coverage.

phyrwork avatar Jan 04 '24 19:01 phyrwork

The tests don't need to cover everything, they look extensive enough to me to warrant a merge.

But you definitely need to fix the failing tests.

felixfontein avatar Jan 16 '24 21:01 felixfontein

@phyrwork ping

needs_info

felixfontein avatar Feb 23 '24 20:02 felixfontein

@phyrwork This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

ansibullbot avatar Mar 26 '24 20:03 ansibullbot

@phyrwork You have not responded to information requests in this pullrequest so we will assume it no longer affects you. If you are still interested in this, please create a new pullrequest with the requested information.

click here for bot help

ansibullbot avatar May 01 '24 20:05 ansibullbot