ripclawffb.helix_core.helix_core_protect module – Manage the protection table on Perforce Helix Core

Note

This module is part of the ripclawffb.helix_core collection (version 1.3.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ripclawffb.helix_core. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: ripclawffb.helix_core.helix_core_protect.

New in ripclawffb.helix_core 1.1.0

Synopsis

  • Manage access control via the Perforce protection table.

  • Supports two modes: ‘entry’ for managing individual entries, ‘replace’ for whole-table management.

  • This module supports check mode.

Requirements

The below requirements are needed on the host that executes this module.

  • P4Python pip module is required

Parameters

Parameter

Comments

charset

aliases: p4charset

string

Character set used for translation of unicode files

Can also use ‘P4CHARSET’ environment variable

Default: "none"

mode

string

entry manages individual protection entries without affecting others

replace replaces the entire protection table with specified entries

Note that state=absent with mode=replace is not allowed for security

Choices:

  • "entry" ← (default)

  • "replace"

password

aliases: p4passwd

string / required

The login password

Can also use ‘P4PASSWD’ environment variable

position

string

Where to insert new entries in the protections table.

Only applies when state=present and mode=entry.

Can be beginning, end, or a zero-based integer index.

If the active protection entry already exists exactly, its position will not be changed. We only insert new entries at position.

Default: "end"

protections

list / elements=dictionary

List of protection entries

Each entry must have access, type, name, host, and path keys

Required when state is present

access

string / required

The access level (list, read, open, write, admin, super, review, =read, =open, =write, =branch)

host

string / required

The host IP/pattern, or * for any host

name

string / required

The user or group name, or * for all

path

string / required

The depot path pattern (e.g., //…, //depot/…)

type

string / required

The type of entity (user or group)

Choices:

  • "user"

  • "group"

server

aliases: p4port

string / required

The hostname/ip and port of the server (perforce:1666)

Can also use ‘P4PORT’ environment variable

state

string

Determines if the protection entries are added or removed

present adds entries (mode=entry) or replaces table (mode=replace)

absent removes matching entries (mode=entry only)

Choices:

  • "present" ← (default)

  • "absent"

user

aliases: p4user

string / required

A user with access to perform this operation

Can also use ‘P4USER’ environment variable

See Also

See also

Helix Core Protect

Manage access permissions

P4Python Pip Module

Python module to interact with Helix Core

Examples

# Add individual protection entries (default mode)
- name: Add developer access
  ripclawffb.helix_core.helix_core_protect:
    state: present
    protections:
      - access: write
        type: group
        name: developers
        host: "*"
        path: //depot/...
    server: '1666'
    user: bruno
    charset: auto
    password: ''

# Remove specific protection entries
- name: Remove contractor access
  ripclawffb.helix_core.helix_core_protect:
    state: absent
    protections:
      - access: read
        type: group
        name: contractors
        host: "*"
        path: //depot/...
    server: '1666'
    user: bruno
    charset: auto
    password: ''

# Replace entire protection table
- name: Set complete protection table
  ripclawffb.helix_core.helix_core_protect:
    state: present
    mode: replace
    protections:
      - access: super
        type: user
        name: admin
        host: "*"
        path: //...
      - access: write
        type: group
        name: developers
        host: "*"
        path: //depot/...
    server: '1666'
    user: bruno
    charset: auto
    password: ''

# Add a base rule at the beginning of the table
- name: Add base rule at beginning
  ripclawffb.helix_core.helix_core_protect:
    state: present
    position: beginning
    protections:
      - access: read
        type: group
        name: everyone
        host: "*"
        path: //...
    server: '1666'
    user: bruno
    charset: auto
    password: ''

# Insert a rule at a specific index
- name: Insert rule at index 2
  ripclawffb.helix_core.helix_core_protect:
    state: present
    position: '2'
    protections:
      - access: write
        type: group
        name: qa_team
        host: "*"
        path: //depot/qa/...
    server: '1666'
    user: bruno
    charset: auto
    password: ''

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

action

string

The action performed on the resource.

Returned: always

Can only return:

  • "updated"

  • "unchanged"

Sample: "updated"

changed

boolean

Whether any changes were made to the protection table.

Returned: always

Sample: true

changes

dictionary

Entries that were added or removed.

Returned: always

Sample: {"added": [{"access": "write", "host": "*", "name": "devs", "path": "//...", "type": "group"}], "removed": []}

diff

dictionary

A dictionary containing ‘before’ and ‘after’ state of the resource.

Returned: when diff mode is enabled

after

string

The state of the resource after the action.

Returned: success

before

string

The state of the resource before the action.

Returned: success

protections

list / elements=dictionary

The protection table entries after the operation.

Returned: always

Sample: [{"access": "super", "host": "*", "name": "admin", "path": "//...", "type": "user"}]

Authors

  • Asif Shaikh (@ripclawffb)