# Newbie variables problem while upgrading from 1.9 to 2.x

**URL:** <https://forum.ansible.com/t/newbie-variables-problem-while-upgrading-from-1-9-to-2-x/26437>\
**Category:** Ansible Project\
**Created:** [January 8, 2018, 11:45am UTC](https://forum.ansible.com/t/newbie-variables-problem-while-upgrading-from-1-9-to-2-x/26437 "2018-01-08T11:45:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Seshadri\_Iyer](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@K\_Seshadri\_Iyer](https://forum.ansible.com/u/K_Seshadri_Iyer)\
**Post date:** [January 8, 2018, 11:45am UTC](https://forum.ansible.com/t/newbie-variables-problem-while-upgrading-from-1-9-to-2-x/26437/1 "2018-01-08T11:45:28Z")

</div>

In the snippet below, if state is absent, then obviously permissions can’t be set on something that is not present. My objective is to run “permissions” only when state is present; else, do nothing.

acl:  
name={{secrets\_dir}}/{{item.0.file}}  
state=“{{‘present’ if item.0.pods is not defined or machine\_pod in item.0.pods else ‘absent’}}”  
entity=“{{item.1.entity}}”  
etype=“{{item.1.etype}}”  
permissions=r  
default=no  
with\_subelements:

- “{{ secrets }}”
- ACL

When I run this task, I get the message which is helpful, but I have been unable to use if-else or omit to solve this problem.

“msg”: “‘permissions’ MUST NOT be set when ‘state=absent’.”

Thanks !

---

<div class="post-metadata">

**Author:** ![K\_Seshadri\_Iyer](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@K\_Seshadri\_Iyer](https://forum.ansible.com/u/K_Seshadri_Iyer)\
**Post date:** [January 11, 2018, 4:36am UTC](https://forum.ansible.com/t/newbie-variables-problem-while-upgrading-from-1-9-to-2-x/26437/2 "2018-01-11T04:36:06Z")

</div>

Answering my own question:

In Ansible 2.x, when state is absent, the permissions field can’t be set. The way out here is to have two clauses (set ACL, remove ACL) each with a “when” like:

name: task(set ACLs)  
…  
…  
when item.0.pods is not defined

name: task(remove ACLs)

…  
…

when not(item.0.pods is not defined)
