Updating a Ansible role which has been installed with ansible-galaxy from a GitHub repo

7k Views Asked by At

Whenever I change code in my Ansible role in a repository, I also want to have that code updated in the roles directory on my test machine. What I do to obtain the new code is to

  1. remove the role by running ansible-galaxy remove rolename
  2. install the role again by using ansible-galaxy install git+https://url/rolename

If I do not use the remove option before the install, ansible-galaxy just skips the role as it's already installed. It does not see the changed files in the repo as such.

What is the best way to achive this?

1

There are 1 best solutions below

1
On

It seems like the recommended path to update a role is to use the --force option.

From ansible-galaxy install --help

  -f, --force           Force overwriting an existing role or collection

For reference, also see those likes in their repository:

So in your case

ansible-galaxy install --force git+https://url/rolename