0

My Ansible playbook looks like below:

- hosts: all
  gather_facts: false
  remote_user: ansadm
  vars:
    dashboard_json: {This is some sample text in JSON  with numerous data in curly braces {{Text}} {{MoreText}}  {{MoreText}}  and many more}

The text that I have in the dashboard_json variable is in JSON format and has multiple text defined within {{ }} that I want to ignore and take it as a text and not a variable. Also, the JSON text is more that 1700 lines in size and I don't want any manual modifications to the text to add the escape sequence.

Is there an easier way out to just take the whole variable data as is?

Any idea, whould be helpful.

0

1 Answer 1

0

In order to use unsafe or raw strings you could try an approach like

---
- hosts: localhost
  become: false
  gather_facts: false

  vars:

    dashboard_json: !unsafe |
      {This is some sample text in JSON  with numerous data in curly braces {{Text}} {{MoreText}}  {{MoreText}}  and many more}

  tasks:

    - name: Show raw string
      debug:
        msg: "{{ dashboard_json }}"

or

    dashboard_json: |
      {% raw -%}
      {This is some sample text in JSON  with numerous data in curly braces {{Text}} {{MoreText}}  {{MoreText}}  and many more}
      {% endraw -%}

resulting into an output of

TASK [Show raw string] ******************************************************************************************************
  msg: |-
    {This is some sample text in JSON  with numerous data in curly braces {{Text}} {{MoreText}}  {{MoreText}}  and many more}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.