Re: [ansible-project] Validate case insensitive values

2021-01-31 Thread Dick Visser
I see. I think 'upper' should be used on a list using 'map': - hosts: localhost connection: local gather_facts: no vars: environments: - DEv - UAt - PrOd tasks: - fail: msg: Your env '{{ env }}' was NOT found in environments when: env|upper not in

Re: [ansible-project] Validate case insensitive values

2021-01-31 Thread PluftPlayzRoblox
The reason it works for you seems to be that you are not changing case for environments. This works: --- - hosts: localhost connection: local gather_facts: no vars: environments: - DeV - Uat - PROD env: d tasks: - fail: msg: Not a valid value when: env|upper

Re: [ansible-project] Validate case insensitive values

2021-01-25 Thread Dick Visser
No it doesn't. It works as you want. (ansible-2.9.15) dick.visser@mbp ~$ ansible-playbook work/tasks/list3.yml -e env=DEV [WARNING]: No inventory was parsed, only implicit localhost is available PLAY [localhost] *** TASK [fail] ***

Re: [ansible-project] Validate case insensitive values

2021-01-25 Thread PluftPlayzRoblox
You have env: Acceptance in there but if you had it DEV or UAT or PROD, it would have worked. I mean If you use DEV or UAT or PROD as value of env, then it's all good which is fine. The problem is when the value of env is just D (first letter of DEV) ie env: D, it still matches DEV. On Mon,

Re: [ansible-project] Validate case insensitive values

2021-01-25 Thread Dick Visser
On Mon, 25 Jan 2021 at 14:54, PluftPlayzRoblox wrote: > > Trying this: > > vars: > environments: ['DEV Managed, UAT in the datacenter, PROD (in the cloud > and data center)’] As I've explained this is incorrect and does not mean what you think it means. >env: NA > > tasks: > - fail: ms

Re: [ansible-project] Validate case insensitive values

2021-01-25 Thread PluftPlayzRoblox
Trying this: vars: environments: ['DEV Managed, UAT in the datacenter, PROD (in the cloud and data center)’] env: NA tasks: - fail: msg="Not valid value" when: env |upper not in environments |upper and with the yaml list, esult is the same, NA matched Managed. What I found is that if

Re: [ansible-project] Validate case insensitive values

2021-01-24 Thread Dick Visser
Your environments variable definition seems to be incorrectly quoted so I'm not even sure what that list looks like now. You can also try the yaml list syntax: environments: - DEV Managed - UAT somewhere else - PROD blah Also you compare 'version' but your example mentions 'env' (which is also

Re: [ansible-project] Validate case insensitive values

2021-01-24 Thread PluftPlayzRoblox
This matches even when part of the version is in an element of environments, eg vars: environments: ['DEV Managed, UAT in the datacenter, PROD in the cloud and data center] env: NA tasks: - fail: msg="Not valid value" when: version|upper not in environments |upper As NA is in Mana

Re: [ansible-project] Validate case insensitive values

2021-01-22 Thread Matt Martz
when: version|upper not in environments On Fri, Jan 22, 2021 at 9:53 AM PluftPlayzRoblox wrote: > > Trying to validate that a specific variable must have one of > pre-determined values, mimicking dropdown in survey in ansible tower/awx. > > I have the following code but it only matches for upper

[ansible-project] Validate case insensitive values

2021-01-22 Thread PluftPlayzRoblox
Trying to validate that a specific variable must have one of pre-determined values, mimicking dropdown in survey in ansible tower/awx. I have the following code but it only matches for upper case: vars: environments: [DEV, UAT, PROD] env: DEV tasks: - fail: msg="Not valid value" w