Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split multiple filters into multiple lines with Ansible?

Here's a task I have on my playbook:

- name: Parse 'LANGUAGE' from current locale and language configuration
  set_fact:
    locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}"

I'm trying to find a way to split that multiple filters line into multiple lines to make it more readable, but nothing I do works. Is it even possible without making the whole thing more complicated to read?

like image 920
rfgamaral Avatar asked Sep 03 '19 18:09

rfgamaral


1 Answers

You can try something like this,

- name: Parse 'LANGUAGE' from current locale and language configuration
  set_fact:
    locale_language: "{{ locale_status.stdout \
                     | regex_search('LANGUAGE=([^\n]+)', '\\1') \
                     | default([locale_lang], true) \
                     | first }}"

As I have tested this below task and it works fine,

tasks:
    - set_fact:
        locale_language: "{{ shubham \
                         | quote }}"
    - debug:
        msg: "{{ locale_language }}"
like image 79
Shubham Vaishnav Avatar answered Sep 28 '22 01:09

Shubham Vaishnav