# Checking if something is both set and unsett (or, is there a better way to do this?)

**URL:** <https://forum.ansible.com/t/checking-if-something-is-both-set-and-unsett-or-is-there-a-better-way-to-do-this/12262>\
**Category:** Ansible Project\
**Created:** [January 29, 2013, 4:44pm UTC](https://forum.ansible.com/t/checking-if-something-is-both-set-and-unsett-or-is-there-a-better-way-to-do-this/12262 "2013-01-29T16:44:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nolan\_Darilek](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@Nolan\_Darilek](https://forum.ansible.com/u/Nolan_Darilek)\
**Post date:** [January 29, 2013, 4:44pm UTC](https://forum.ansible.com/t/checking-if-something-is-both-set-and-unsett-or-is-there-a-better-way-to-do-this/12262/1 "2013-01-29T16:44:55Z")

</div>

I have a setup task that runs when I first create a server, and also at various points in larger playbooks so I can ensure that the baseline state is still maintained. On initial run, ansible\_fqdn isn't necessarily correct, so I pass in a fqdn variable on the command line. After that. If I don't explicitly pass fqdn, it can be assumed that ansible\_fqdn is accurate.

I also push out SSL certificates by default, but have introduced a noSSL flag for simple hosts that I don't care to set up SSL on.

So I have tasks that look like this:

&nbsp;&nbsp;&nbsp;- name: Copy SSL certificate  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy: src=../ssl/$fqdn.crt dest=/etc/ssl/certs mode=0400  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_set: $fqdn  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# when\_unset: $noSSL  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# notify: $sslHandlers  
&nbsp;&nbsp;&nbsp;- name: Copy SSL key  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy: src=../ssl/$fqdn.key dest=/etc/ssl/private mode=0400  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_set: $fqdn  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# when\_unset: $noSSL  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# notify: $sslHandlers  
&nbsp;&nbsp;&nbsp;- name: Copy SSL certificate  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy: src=../ssl/$ansible\_fqdn.crt dest=/etc/ssl/certs mode=0400  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_unset: $fqdn and $noSSL  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# notify: $sslHandlers  
&nbsp;&nbsp;&nbsp;- name: Copy SSL key  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy: src=../ssl/$ansible\_fqdn.key dest=/etc/ssl/private mode=0400  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_unset: $fqdn and $noSSL  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# notify: $sslHandlers

Except the first two with $fqdn don't work with the when\_unset uncommented. Basically I'd like to check that fqdn is defined and noSSL isn't. Is there a way to do this?

Even better would be to get rid of this duplication and, say, set fqdn to a command line value, or to ansible\_fqdn if it isn't defined. Then the when\_set can go, and I'm only checking for one condition. Is this doable?

Thanks.
