In Ansible, how to use a variable inside a variable definition that uses filters
问题 I want to extract a few regex matches out of a URL. The only way I could do this was following: - name: Set regex pattern for github URL set_fact: pattern="^(git\@github\.com\:|https?\:\/\/github.com\/)(.*)\/([^\.]+)(\.git)?$" - name: Extract organization name set_fact: project_repo="{{ deploy_fork | regex_replace( "^(git\@github\.com\:|https?\:\/\/github.com\/)(.*)\/([^\.]+)(\.git)?$", "\\3" ) }}" when: deploy_fork | match( "{{ pattern }}" ) With this approach, I'm able to reuse the variable