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

New module - helix_configurable #57594

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@ripclawffb
Copy link

commented Jun 10, 2019

SUMMARY

Adding a module to manage various configuration options of a Perforce Helix Core server.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

helix_configurable

ADDITIONAL INFORMATION

This module requires the p4python library

Integration Test Results:

$ test/runner/ansible-test integration unsupported/helix_configurable
Running helix_configurable integration test role

PLAY [testhost] **************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************
ok: [testhost]

TASK [helix_configurable : Install required lib] *****************************************************************
ok: [testhost]

TASK [helix_configurable : Set auth.id for any server id] ********************************************************
changed: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_configurable": {
        "changed": true,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Set auth.id for any server id (idempotent)] *******************************************
ok: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_configurable_idempotent": {
        "changed": false,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Unset auth.id for any server id] ******************************************************
changed: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_configurable": {
        "changed": true,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Set auth.id for specific server (check mode)] *****************************************
changed: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_serverid_configurable": {
        "changed": true,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Set auth.id for specific server] ******************************************************
changed: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_serverid_configurable": {
        "changed": true,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Unset auth.id for specific server id] *************************************************
changed: [testhost]

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_unset_serverid_configurable": {
        "changed": true,
        "failed": false
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Fail when using invalid login] ********************************************************
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error: There was a problem in connecting to Helix: [P4#run] Errors during command execution( \"p4 login\" )\n\n\t[Error]: \"Access for user 'bruno1' has not been enabled by 'p4 protect'.\"\n\n"}
...ignoring

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_invalid_login": {
        "changed": false,
        "failed": true,
        "msg": "Error: There was a problem in connecting to Helix: [P4#run] Errors during command execution( \"p4 login\" )\n\n\t[Error]: \"Access for user 'bruno1' has not been enabled by 'p4 protect'.\"\n\n"
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [helix_configurable : Fail when using invalid port] *********************************************************
fatal: [testhost]: FAILED! => {"changed": false, "msg": "Error: There was a problem in connecting to Helix: [P4.connect()] Connect to server failed; check $P4PORT.\nTCP connect to 1999 failed.\nconnect: 127.0.0.1:1999: Connection refused\n"}
...ignoring

TASK [helix_configurable : debug] ********************************************************************************
ok: [testhost] => {
    "auth_set_invalid_port": {
        "changed": false,
        "failed": true,
        "msg": "Error: There was a problem in connecting to Helix: [P4.connect()] Connect to server failed; check $P4PORT.\nTCP connect to 1999 failed.\nconnect: 127.0.0.1:1999: Connection refused\n"
    }
}

TASK [helix_configurable : assert] *******************************************************************************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

PLAY RECAP *******************************************************************************************************
testhost                   : ok=26   changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=2

@ripclawffb ripclawffb changed the title Initial release of helix_configurable module New module - helix_configurable Jun 10, 2019

@ansibot ansibot added the stale_ci label Jun 18, 2019

@ripclawffb

This comment has been minimized.

Copy link
Author

commented Jun 24, 2019

bot_status

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2019

Components

lib/ansible/modules/source_control/perforce/init.py
support: community
maintainers:

lib/ansible/modules/source_control/perforce/helix_configurable.py
support: community
maintainers:

test/integration/targets/helix_configurable/aliases
support: community
maintainers:

test/integration/targets/helix_configurable/tasks/main.yml
support: community
maintainers:

Metadata

waiting_on: maintainer
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 0
shipit_actors (maintainer or core team member): []
shipit_actors_other: []
automerge: automerge shipit test failed

click here for bot help

)

if not HAS_P4:
module.fail_json(msg="Missing required lib 'p4python'")

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jun 24, 2019

Contributor

Use missing_required_lib to generate the message.

This comment has been minimized.

Copy link
@ripclawffb

ripclawffb Jun 25, 2019

Author

Updated to use missing_required_lib

module.fail_json(msg="Missing required lib 'p4python'")

# connect to helix
p4 = helix_connect(module.params['p4user'], module.params['p4port'], module.params['p4passwd'], 'ansible')

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jun 24, 2019

Contributor

Does this raise an exception if it can't connect? You should catch that and call module.fail_json() with an appropriate message.

This comment has been minimized.

Copy link
@ripclawffb

ripclawffb Jun 24, 2019

Author

Yes, in the next few lines, if a connection object is not returned, a string is returned with the connection error message.

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jun 24, 2019

Contributor

That's quite a strange (and un-pythonic) way to indicate failure. But if the library does that, there's not much you can do :)

This comment has been minimized.

Copy link
@ripclawffb

ripclawffb Jun 25, 2019

Author

Refactored this to create a shared module as it can be used by other Perforce modules in the future. In case of a connection error, the function will call the module.fail_json() with an appropriate error message.

Example error message:

failed: [localhost] (item={u'name': u'server.commandlimits', u'value': 2}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "server.commandlimits", "value": 2}, "msg": "There was a problem connecting to Helix: [P4#run] Errors during command execution( \"p4 login\" )\n\n\t[Error]: \"Access for user 'bruno1' has not been enabled by 'p4 protect'.\"\n\n"}

@ansibot ansibot removed the stale_ci label Jun 25, 2019

@ripclawffb ripclawffb force-pushed the ripclawffb:perforce/helix_configurable branch from 79f1a9f to 871334c Jun 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.