0

I am just diving into hosting custom made roles in a private gitlab git repository.

The answer to this may just be "you must have only 1 repo for 1 role," which I have not done. I have tried to put two roles in a repo and have just used folders to differentiate them at the top level.

I seem to have gotten the "requirements.yml" written correctly, as it pulled my roles. However it is putting all the files from 'nexus' into my skeleton role of 'chocolatey_factory'. The 'nexus' imported role comes across fine.

My requirements file is the following:

---
- src: git+ssh://git@[local_ip_address]/gitlab-instance-937dde58/my_first_project.git
  scm: git
  version: main
  name: nexus

- src: git+ssh://git@[local_ip_address]/gitlab-instance-937dde58/my_first_project.git
  scm: git
  version: main
  name: chocolatey_factory

Here is my repo layout. The idea is I would have each folder at the top level of the repo be a role. So in this case, I have two roles.

Top Level of Repo

nexus folder/role files

chocolatey_factory galaxy init folder

What am I doing wrong here?

One is 'nexus,' the other is 'chocolatey_factory'. Nexus is the public role available for configuring Sontaype nexus that I grabbed. Chocolatey_factory is one I am making, but it is just a ansible-galaxy init skeleton at this time:

I then run my ansible-galaxy command

ansible-galaxy install -r roles/requirements.yml -p roles/

It imports the roles. But the files from 'nexus' role appear in the 'chocolatey_factory' role.

The 'nexus' role has files like pom.xml, where the 'chocolatey_factory' does not have anything other than what ansible-galaxy init creates (ie it does not have a pom.xml file).

You can see here both folders have all the same files.

ls roles
chocolatey_factory  nexus  requirements.yml

ls roles/chocolatey_factory
chocolatey_factory  filter_plugins  molecule          tasks
CODE_OF_CONDUCT.md  handlers        pom.xml           templates
defaults            LICENSE.md      README.md         tests
files               meta            requirements.txt  vars

ls roles/nexus
chocolatey_factory  filter_plugins  molecule          tasks
CODE_OF_CONDUCT.md  handlers        pom.xml           templates
defaults            LICENSE.md      README.md         tests
files               meta            requirements.txt  vars

Why are my files from one role being inserted into the other? Can you not have two roles in the same git repository?

ZZTest
  • 89
  • 7
  • Have you tried their [namespace URI mechanism](https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#specifying-the-location-to-search-for-collections)? – mdaniel Jul 28 '21 at 15:30
  • i gave that a try but i dont think I have the pre-reqs defined to create a collection. Do I need to add a yml file of some sort? – ZZTest Jul 29 '21 at 20:07
  • I haven't tried messing with galaxy since the dreadful ansible 3.0 cut-over, so I don't have tactical experience to offer. That said, you seem to be straddling the old world of one repo per role and the new world of the collections that will tolerate what you're trying to do with your monorepo. Thus, it may be worth your time to pick one style or the other – mdaniel Jul 29 '21 at 20:47

0 Answers0