Conditionals within roles

I have a playbook with a role

  • hosts: somehost
    roles:
  • role: community.some.role
    hostname: “{{ansible_hostname}}”
    server: 192.168.1.2
    api_server_url: https://some.server.com
    url_path: /api
    api_use_ssl: yes
    userparameters:
  • name: SomeName

The last task I want to be dynamic. Based on a fact, I want SomeName to change to a null, File1, File2, File3, etc.

How does one do this in Ansible?

Use ternary, or some inline jinja statements

Wow, I didn’t know ternary existed. Jinja looks more flexible, but I think for this case the same line with different ternary statements should do the job. Thanks!