ansible.builtin.lines (v2.16.5) — lookup

read lines from command

| "added in version" 0.9 of ansible.builtin"

Authors: Daniel Hokka Zakrisson (!UNKNOWN) <daniel@hozac.com>

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

Run one or more commands and split the output into lines, returning them as a list

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: We could read the file directly, but this shows output from command
  ansible.builtin.debug: msg="{{ item }} is an output line from running cat on /etc/motd"
  with_lines: cat /etc/motd
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: More useful example of looping over a command result
  ansible.builtin.shell: "/usr/bin/frobnicate {{ item }}"
  with_lines:
    - "/usr/bin/frobnications_per_host --param {{ inventory_hostname }}"

Inputs

    
_terms:
    description: command(s) to run
    required: true

Outputs

_list:
  description:
  - lines of stdout from command
  elements: str
  type: list