11

I think this is the part of the playbook that is generating the error. How should I be re-writing this part?

roles: 
- role: json-transform
  json_transforms: '{{ clientValidation.json_transforms}}'

It throws the following warning:

[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{json_transforms}}'). This feature will be removed in a 
future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ydaetskcoR
  • 53,225
  • 8
  • 158
  • 177
anuiq
  • 119
  • 2
  • 6
  • What Ansible version are you using? That syntax looks a little odd to me and normally I'd go with something like: `- { role: json-transform, json_transforms: '{{ clientValidation.json_transforms}}' }` so you might want to try that. – ydaetskcoR Apr 26 '16 at 18:05
  • I am using Ansible 2.0.1 I had already tried what you mentioned and it did not work. – anuiq Apr 26 '16 at 21:20
  • 1
    The syntax doesn't matter- @ydaetskcoR is just using inline dict syntax instead of expanded yaml dict syntax. They're exactly the same thing in the parsed document. – nitzmahone Apr 27 '16 at 21:27
  • Seems this question is somehow related to this topic here [1]. Usually happens when you try to validate using then "when" method on a bare variable. From ansible 2.8 and above you should use something like ```when: myVariable|bool``` to be in compliance with the newest standards [1] https://github.com/geerlingguy/ansible-role-ntp/issues/59 – isca Oct 15 '20 at 21:01

1 Answers1

12

It doesn't look like there's anything wrong with your top level- it's probably something inside your role. Deprecated bare variables usually occur on a with_xxx loop; eg:

- hosts: blar
  vars:
    items:
    - one
    - two
  tasks:
  - debug: msg="hi from {{ item }}"
    with_items: items

In this case, it's telling you that with_items: items should be with_items: "{{ items }}".

nitzmahone
  • 13,720
  • 2
  • 36
  • 39