Max Block
Max Block

Reputation: 1444

How to install galaxy role with a different name than in git url?

There is a galaxy role: [email protected]/ansible-myapp.git

I can install it like this:

ansible-galaxy install [email protected]/ansible-myapp.git

, but it creates a role with the name "ansible-myapp".

How can I install a role with a different name than in git url?

It's possible to do via requirements.yml:

- src: [email protected]/ansible-myapp.git
  scm: git
  name: myapp

ansible-galaxy install -r requirements.yml will install it with the name "myapp"

But how to do it in one command without requirements.yml file?

Upvotes: 5

Views: 653

Answers (1)

Zeitounator
Zeitounator

Reputation: 44615

Found this actually undocumented feature (at least I did not find the doc) with trial and error, extrapolating from the official doc

Add the desired name after the version.

ansible-galaxy role install [email protected]/ansible-myapp.git,master,myapp

This will install the role as myapp using the specified version. For master version, if this is the default repository branch, you can pass an empty version which will default to it:

ansible-galaxy role install [email protected]/ansible-myapp.git,,myapp

This was tested with:

$ ansible-galaxy --version
ansible-galaxy 2.9.10
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible-galaxy
  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]

NOTE: The TYPE positional argument role in the above command line was introduced to differentiate roles and collections, and will default to role if omitted (for compatibility with previous ansible galaxy versions)

Upvotes: 5

Related Questions