Hi List,

I've always been following along with the examples here:
http://docs.ansible.com/ansible/playbooks_conditionals.html#the-when-statement

for instance:

```
- 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.
```

When I change the code to this:

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

I get the error:
```
fatal: [10.20.113.218]: FAILED! => {"failed": true, "msg": "The conditional 
check '{{ ansible_os_family }} == 'RedHat' and {{ 
ansible_distribution_major_version }} == '7'' failed. The error was: error 
while evaluating conditional ({{ ansible_os_family }} == 'RedHat' and {{ 
ansible_distribution_major_version }} == '7'): 'Debian' is undefined\n\nThe 
error appears to have been in 
'/home/mark/Documents/persgroep-aws/roles/vnucommon/tasks/main.yml': line 
8, column 3, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Disable 
requiretty\n  ^ here\n"}
```

Am I missing something here?

Thanks,
Mark Maas

-- 
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/7318cc22-72c8-456b-a19a-20d7d6d007a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to