openafs_contrib.openafs.counter (1.9.0) — lookup

Increment named integer counters.

Authors: Michael Meffie

Install collection

Install with ansible-galaxy collection install openafs_contrib.openafs:==1.9.0


Add to requirements.yml

  collections:
    - name: openafs_contrib.openafs
      version: 1.9.0

Description

Counter values are saved in a json file on the controller. The default location of the counter file is C(~/.ansible/counter.json) Set the C(ANSIBLE_OPENAFS_COUNTER_DIR) environment variable to specify an alternate location.

By default, the the M(counter) lookup plugin increments then returns the incremented counter value.

Specify the C(,current) suffix on the counter name to retrieve the current counter value without incrementing the counter.

Specify the C(,reset) suffix on the counter name to reset the counter value to zero.

File locking used for mutual exclusion in case more than one playbook is running at a time.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Lookup the current value of test_a."
  debug:
    msg: "{{ lookup('openafs_contrib.openafs.counter', 'test_a,current') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Increment counter test_a."
  debug:
    msg: "{{ lookup('openafs_contrib.openafs.counter', 'test_a') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Increment counters using 'with_' syntax."
  debug:
    var: item
  with_openafs_contrib.openafs.counter:
    - test_a
    - test_b
    - test_c
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Reset counters using 'with_' syntax."
  assert:
    that: item == 0
  with_openafs_contrib.openafs.counter:
    - test_a,reset
    - test_b,reset
    - test_c,reset

Inputs

    
_terms:
    description:
    - list of counter names, in the form I(<name>[,<operation>]), where I(<name>) is the
      counter name and I(<operation>) is one of C(next), C(current), C(reset)
    - The default operation is C(next)
    required: true

Outputs

_list:
  description: List of counter values.
  elements: int
  type: list