On Wednesday, May 11, 2016 at 4:31:12 PM UTC+2, Kai Stian Olstad wrote:
>
> > ``` 
> > - name: Disable requiretty 
> >   lineinfile: 
> >     dest: /etc/sudoers 
> >     regexp: "Defaults    requiretty" 
> >     line: "# Defaults    requiretty" 
> >   when: ansible_os_family == "RedHat" and 
> > ansible_distribution_major_version == "7" 
> > ``` 
> > 
> > But when I run that with Ansible > 2.0 it gives me a deprecation 
> message: 
> > 
> > ``` 
> > [DEPRECATION WARNING]: Using bare variables is deprecated. Update your 
> > playbooks so that the environment value uses the full variable syntax 
> > ('{{ansible_os_family}}'). 
> > This feature will be removed in a future release. 
> > ``` 
>
> Are you sure that this message is because of the when statement and not 
> from other places you have used a variable? 
>


Yes, I've seem to have been able to fix it like so:

```
- name: Disable requiretty
  lineinfile:
    dest: /etc/sudoers
    regexp: "Defaults    requiretty"
    line: "# Defaults    requiretty"
  when: "'{{ ansible_os_family }}' == 'RedHat' and '{{ 
ansible_distribution_major_version }}' == '7'"
```

Apparantly one needs to use, double quotes, single quotes and accolades to 
make ansible 2.0 happy.

This should actually be fixed in the docs, those pages are simply wrong at 
the moment.

 

>
> According to Brian Coca in this post {{ and }} is implied in when and 
> should not be used. 
>
> https://groups.google.com/forum/#!msg/ansible-project/1DyCROTgMF0/6siUigwuAQAJ
>  
>


Now I'm lost, when I leave those out, ansible cries foul and throws me a 
deprectation warning.
 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c06adc66-f924-4440-a59f-3cd5672561b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to