community / community.general / 8.5.0 / module / pids Retrieves process IDs list if the process is running otherwise return empty list Authors: Saranya Sridharan (@saranyasridharan)community.general.pids (8.5.0) — module
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
Retrieves a list of PIDs of given process name in Ansible controller/controlled machines.Returns an empty list if no process in that name exists.
# Pass the process name - name: Getting process IDs of the process community.general.pids: name: python register: pids_of_python
- name: Printing the process IDs obtained ansible.builtin.debug: msg: "PIDS of python:{{pids_of_python.pids|join(',')}}"
- name: Getting process IDs of processes matching pattern community.general.pids: pattern: python(2(\.7)?|3(\.6)?)?\s+myapp\.py register: myapp_pids
name: description: The name of the process(es) you want to get PID(s) for. type: str pattern: description: The pattern (regular expression) to match the process(es) you want to get PID(s) for. type: str version_added: 3.0.0 version_added_collection: community.general ignore_case: default: false description: Ignore case in pattern if using the O(pattern) option. type: bool version_added: 3.0.0 version_added_collection: community.general
pids: description: Process IDs of the given process returned: list of none, one, or more process IDs sample: - 100 - 200 type: list