0

i want to install some roles from my requirements.yaml file ,

which looks like this :

requirements.yaml:

- src: git@gitlab.company.com:mygroup/ansible-base.git
  scm: git
  version: "mybranch" #MY BRANCH AS PARAMETER

to install , i'm used to run this command :

ansible-galaxy install -f -r playbook/requirements.yaml

my purpose is how to configure my file to get the version attribute value as parameter , something like this

  version: "{{branch_var}}" #MY BRANCH AS PARAMETER

and be able to pass that parameter from with the command line , sometjhing like this :

ansible-galaxy install -f -r playbook/requirements.yaml -e branch_var="mybranch"

Is that possible ? , if not is there any alternative ?

firasKoubaa
  • 6,439
  • 25
  • 79
  • 148
  • 1
    This is not possible. The only alternative I see is to create a "template" requirement file where you interpolate your local variables (with something like [`envsubst`](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) prior to using it. Meanwhile, I am quite curious to know the exact use case where you would need this as version of dependencies should IMO be fixed depending on you project version and should not change over time for a given version. – Zeitounator Jan 02 '20 at 11:40
  • 1
    FWIW. See also [Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#). – Vladimir Botka Jan 02 '20 at 12:25

0 Answers0