Install Roles with requirements.yml
Pin and fetch dependencies.
Install Roles with requirements.yml is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
Stop Installing By Hand
Running install commands one by one does not scale. A requirements.yml file lists every dependency so the whole project installs in one shot.
A Manifest for Dependencies
Think of requirements.yml as your package manifest: it declares exactly which roles and collections your playbooks need to run.
List Roles Under roles
Inside the file, a roles key holds a list. Each entry names one role to fetch from Galaxy by its author.name handle.
roles:
- name: geerlingguy.nginxList Collections Too
A separate collections key lists collections by their namespace.collection name, so one file covers both content types.
collections:
- name: community.generalPin a Version
Always add a version so installs are reproducible. Without it you may pull a newer, breaking release on a teammate's machine.
roles:
- name: geerlingguy.nginx
version: "3.1.4"Install Everything at Once
Point ansible-galaxy at the file with -r and it resolves and installs every listed dependency in a single command.
ansible-galaxy install -r requirements.ymlCollections Need Their Own Run
The plain install command handles roles. For collections, use the collection install subcommand with the same -r flag.
ansible-galaxy collection install -r requirements.ymlPull from Git, Not Just Galaxy
A role entry can use a src Git URL instead of a Galaxy name, letting you install private or unpublished roles.
roles:
- src: https://github.com/acme/role-app.git
version: mainChoose an Install Path
Add -p to drop roles into a project-local folder like roles/ instead of the global path, keeping each project self-contained.
ansible-galaxy install -r requirements.yml -p roles/Force a Refresh
By default existing roles are kept. Pass --force to re-download and overwrite them when you bump a pinned version.
ansible-galaxy install -r requirements.yml --forceCommit the File, Not the Roles
Check requirements.yml into Git but ignore the downloaded role folders. Anyone can rebuild the exact set from the manifest.
Quick Check
Recall how to install everything a project depends on.
Recap
List roles and collections in requirements.yml, pin versions, then install them all with ansible-galaxy -r. One file, reproducible setups. 📦
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Install Roles with requirements.yml” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Install Roles with requirements.yml”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Install Roles with requirements.yml”?
Pin and fetch dependencies. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.
How long does the “Install Roles with requirements.yml” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Roles vs Collections on Galaxy
- Install Roles with requirements.yml
- Using FQCN: namespace.collection.module
- Publishing Your Own Role to Galaxy