'when not' conditional?

I’d like to have SSL certificates uploaded and configured according to hostname, ie. host1 gets the cert and key for host1, etc.

It seems like the easiest way is to set a variable to equal ansible_hostname, but I’d need a way to handle exceptions, so if ansible_hostname isn’t one of an expected set of values, the variable could be set to some default value. What would be the best way to accomplish something like this?

Hi John, I believe

  • set_fact: foo={{ansible_hostname|default(‘default_ value’)}}

should do what you want.

John Oliver <jnojr1@gmail.com> napisał:

I'd like to have SSL certificates uploaded and configured according to
hostname, ie. host1 gets the cert and key for host1, etc.

It seems like the easiest way is to set a variable to equal
ansible_hostname, but I'd need a way to handle exceptions, so if
ansible_hostname isn't one of an expected set of values, the variable
could
be set to some default value. What would be the best way to accomplish

something like this?

Try something like {{ ansible_hostname if ansible_hostname in list_of_expected_values else the_default }}