'when not' conditional?

69 views
Skip to first unread message

John Oliver

unread,
Sep 17, 2014, 5:20:34 PM9/17/14
to ansible...@googlegroups.com
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?

James Cammarata

unread,
Sep 17, 2014, 8:01:10 PM9/17/14
to ansible...@googlegroups.com
Hi John, I believe 

- set_fact: foo={{ansible_hostname|default('default_ value')}} 

should do what you want.

On Wed, Sep 17, 2014 at 4:20 PM, John Oliver <jno...@gmail.com> wrote:
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?

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c6565db5-2c7b-4c5b-ba90-f3eaf6bdd0bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomasz Kontusz

unread,
Sep 19, 2014, 1:45:19 AM9/19/14
to ansible...@googlegroups.com


John Oliver <jno...@gmail.com> napisał:
Try something like {{ ansible_hostname if ansible_hostname in list_of_expected_values else the_default }}
--
Wysłane za pomocą K-9 Mail.
Reply all
Reply to author
Forward
0 new messages