# Importing role from repo

**URL:** <https://forum.ansible.com/t/importing-role-from-repo/39109>\
**Category:** Get Help\
**Tags:** rhel, aap, awx, galaxy-ng\
**Created:** [December 12, 2024, 4:32pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109 "2024-12-12T16:32:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fracture7144](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fracture7144](https://forum.ansible.com/u/Fracture7144)\
**Post date:** [December 12, 2024, 4:32pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/1 "2024-12-12T16:32:29Z")

</div>

I am trying to setup a new common role to run on all my servers. This role could be run from AWX/AAP or Ad-hoc from a jump server. I want to import other roles from my git repo. It could be bitbucket or github, etc. In previous versions of ansible there were examples to use import\_roles with a remote source. Is there a module that I need to use?  
I am using the latest version of Ansible on RHEL 8/9.  
An example would be something like this.

This is what I think I need to do:

```auto
- import_role: https://git.example.com/something/repo.git

```

This is what I want to use.

```auto
# from github
- src: https://github.com/bennojoy/nginx

# from Bitbucket
- src: git+https://bitbucket.org/willthames/git-ansible-galaxy
  version: v1.4

```

Which is the better way to do accomplish this?

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [December 12, 2024, 4:50pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/2 "2024-12-12T16:50:08Z")

</div>

run `ansible-galaxy` to install roles, Ansible imports and includes can ONLY work with installed resources, they won’t fetch and install for you.

---

<div class="post-metadata">

**Author:** ![Fracture7144](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fracture7144](https://forum.ansible.com/u/Fracture7144)\
**Post date:** [December 12, 2024, 4:52pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/3 "2024-12-12T16:52:30Z")

</div>

That’s fine if I run it ad-hoc. What if I need to call roles, when using AAP/AWX?

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [December 12, 2024, 4:54pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/4 "2024-12-12T16:54:47Z")

</div>

awx/AAP have a ‘auto install’ if you set requirements file under roles/ [13. Projects — Ansible Tower User Guide v3.4.4](https://docs.ansible.com/ansible-tower/3.4.4/html/userguide/projects.html#ug-galaxy)

---

<div class="post-metadata">

**Author:** ![Fracture7144](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fracture7144](https://forum.ansible.com/u/Fracture7144)\
**Post date:** [December 12, 2024, 4:56pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/5 "2024-12-12T16:56:52Z")

</div>

If I tell the role to use a requirements.yml do I need specify it in the tasks/main.yml or will it automatically pick it up?

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [December 12, 2024, 4:58pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/6 "2024-12-12T16:58:41Z")

</div>

it is not part of a role, it is in the roles/ directory of the job’s project

---

<div class="post-metadata">

**Author:** ![Fracture7144](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fracture7144](https://forum.ansible.com/u/Fracture7144)\
**Post date:** [December 12, 2024, 5:00pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/7 "2024-12-12T17:00:54Z")

</div>

hmmm. ok I will need to review this then.

---

<div class="post-metadata">

**Author:** ![Fracture7144](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fracture7144](https://forum.ansible.com/u/Fracture7144)\
**Post date:** [January 8, 2025, 4:40pm UTC](https://forum.ansible.com/t/importing-role-from-repo/39109/8 "2025-01-08T16:40:43Z")

</div>

Hi, circling back to this, if I use the ansible galaxy module to install the roles but don’t specify the destination will they be cleaned up when the job is done?

- name: Install role at specific path  
community.general.ansible\_galaxy\_install:  
type: role  
name: ansistrano.deploy
