-2

Syntax Error while loading YAML. found unknown escape character

The error appears to be in line 111, column 25, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • set_fact: rollback: " {{ reg3['user_input'] }} " ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance:

    with_items:

    • {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"

After upgrading ansible version to ansible 2.9.17 and python version to python version = 3.6.8 this syntax error is coming

- set_fact:
      reg2: "{{ reg1.stdout[0] }}"
  - set_fact:
      desc: " {{ reg2.split(\"   \")[-1] }} "
  - pause:
       prompt: "confirm Y/N:"
    register: reg3
  - set_fact:
      rollback: " {{ reg3[\'user_input\'] }} "
  • set_fact: desc: " {{ reg2.split(' ')[-1] }} " or '{{ reg2.split(" "')[-1] }} ',as you want and please show more line of your's playbook, if you want an help. – Derioss Feb 24 '21 at 15:49
  • 2
    Please [edit your question](https://stackoverflow.com/posts/66353487/edit) and fix the formatting – mdaniel Feb 24 '21 at 17:06
  • Hi Thank you . issue got resolved.... rollback: " {{ reg3[\'user_input\'] }} " is not working with single quotations only working as rollback: " {{ reg3[\"user_input\"] }} " – Gopi Pulivarthi Feb 25 '21 at 04:39

1 Answers1

0

issue got resolved....

enter code here

non working scenario

rollback: " {{ reg3[\'user_input\'] }} "

working scenario

rollback: " {{ reg3[\"user_input\"] }} "

  • Your answer would be more helpful to others if you edited it to fix the syntax, because as it is written SO is swallowing the `\\` characters which are the underlying root issue with your problem. No one would know that just by reading this anwer – mdaniel Feb 25 '21 at 17:00
  • I have edited as you suggested.., Thank You – Gopi Pulivarthi Feb 26 '21 at 10:19