gitansibleansible-galaxy

Install Ansible Galaxy role as git repository


I have a requirements.yml file with the following contents:

- src: git@github.com:SomeOrg/SomeRole.git
  scm: git
  version: master
  name: some-role

If I run ansible-galaxy, the role gets includes in the roles directory as expected. The role ends up being an export of the desired git revision rather than a git repository itself. Is there a way to tell ansible-galaxy to pull in the role as git repository?

Composer, the PHP package manager, does this by default. Having the dependencies you pull in being git repositories where applicable makes it a lot easier to make changes to those.


Solution

  • TLDR; => ansible-galaxy role install -fgr roles/requirements.yml


    This is not really clear IMO in the help message but that is the option you are looking for:

    $ ansible-galaxy install --help
    [...]
      -g, --keep-scm-meta   Use tar instead of the scm archive option when
                            packaging the role.
    

    You will probably want to ignore the meta/.galaxy_install_info file that galaxy is creating upon import inside the role.