ansible.builtin.ini (v2.8.15) — lookup

read data from a ini file

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

Authors: Yannig Perre <yannig.perre(at)gmail.com>

Install Ansible via pip

Install with pip install ansible==2.8.15

Description

The ini lookup reads the contents of a file in INI format C(key1=value1). This plugin retrieves the value on the right side after the equal sign C('=') of a given section C([section]).

You can also read a property file which - in this case - does not contain section.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="User in integration is {{ lookup('ini', 'user section=integration file=users.ini') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="User in production  is {{ lookup('ini', 'user section=production  file=users.ini') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="user.name is {{ lookup('ini', 'user.name type=properties file=user.properties') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: "{{ item }}"
  with_ini:
    - '.* section=section1 file=test.ini re=True'

Inputs

    
re:
    default: false
    description: Flag to indicate if the key supplied is a regexp.
    type: boolean

file:
    default: ansible.ini
    description: Name of the file to load.

type:
    choices:
    - ini
    - properties
    default: ini
    description: Type of the file. 'properties' refers to the Java properties files.

_terms:
    description: The key(s) to look up
    required: true

default:
    default: ''
    description: Return value if the key is not in the ini file.

section:
    default: global
    description: Section where to lookup the key.

encoding:
    default: utf-8
    description: Text encoding to use.

Outputs

_raw:
  description:
  - value(s) of the key(s) in the ini file