I'm working on the project and I'm stuck right now. My question is I'm trying to deploy aws lambda function using ansible tower temple and we have multiple aws account but naming standard include dev or prod. Is there a way and any example that show's how to include inventory name in ansible script.
For example under ansible tower (inventories), I have few inventories like "example-dev-standard, "example-prod-standard" and I just want to take the prod or dev out of that name using regex and make it as a variable which I'm also using this variable on other place in the script
- name: Set environment fact
set_fact:
test: "{{ ???????? | regex_replace('(?i).*(dev|prod).*', '\\1') | lower }}"
# Test test var
- name: Ensure test fact is either dev or prod
assert:
that: test == "dev" or test == "prod"
msg: "Error: the test fact was not set properly, check the account alias to ensure the string dev or prod exists"