# How to bypass (Conditional is marked as unsafe)

**URL:** <https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973>\
**Category:** Get Help\
**Created:** [February 21, 2024, 12:52pm UTC](https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973 "2024-02-21T12:52:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![souovan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/souovan/32/1637_2.png) [@souovan](https://forum.ansible.com/u/souovan)\
**Post date:** [February 21, 2024, 12:52pm UTC](https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973/1 "2024-02-21T12:52:23Z")

</div>

My playbook evaluates in the `when` clause a variable that is input from Survey on Ansible Automation Platform, but i now i get `Conditional is marked as unsafe`

code:

```yaml
task

    - name: Creating user on CentOS7 ( with wheel )
      ansible.builtin.user:
        name: "{{ user }}"
        password: "{{ passwd | password_hash('sha512') }}"
        shell: "{{ user_shell }}"
        append: yes
        state: present
        comment: Created by Ansible
        group: "{{ user }}"
        groups: wheel
      when: ansible_distribution == "CentOS" and "{{ root }}" == "yes"

```

Reference:  
[https://docs.ansible.com/ansible/latest/porting\_guides/porting\_guide\_9.html](https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_9.html)

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [February 21, 2024, 1:00pm UTC](https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973/2 "2024-02-21T13:00:46Z")

</div>

The condition contains an embedded template (`{{ root }}`). Bare variables are already templated, so to fix you should remove the brackets and encapsulate the whole conditional in quotation marks:

`when: 'ansible_distribution == "CentOS" and root == "yes"'`

---

<div class="post-metadata">

**Author:** ![souovan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/souovan/32/1637_2.png) [@souovan](https://forum.ansible.com/u/souovan)\
**Post date:** [February 21, 2024, 1:14pm UTC](https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973/3 "2024-02-21T13:14:44Z")

</div>

Thank you, it worked !!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 22, 2024, 1:14pm UTC](https://forum.ansible.com/t/how-to-bypass-conditional-is-marked-as-unsafe/3973/4 "2024-03-22T13:14:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
