7

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?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Rob
  • 71
  • 1
  • 2

1 Answers1

4

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
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • 2
    This is utterly ridiculous considering the most fundamental principle of Ansible is idempotency. What were they thinking... – bviktor Dec 02 '22 at 02:43