Loading...

Watch: Download and Use Ansible Galaxy Role - ansible-galaxy and requirements.yml

Learn how to download and use the Ansible Galaxy Role lucab85.ansible_role_log4shell with ansible-core, including a step-by-step example.

How to Download and Use Ansible Galaxy Role with ansible-galaxy and requirements.yml?

I’m going to show you a live Playbook with some simple Ansible code.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

What is an Ansible Role?

  • re-usable Ansible artifacts
  • one role contains tasks, variables, defaults, handlers, modules, or other plugins
  • easy to download and share via Ansible Galaxy

An Ansible Role is a set of re-usable Ansible artifacts.

It solves one problem and contains all the relevant tasks, variables, defaults, handlers, modules, or other plugins.

For Users, the Ansible Role is easy to download and share via Ansible Galaxy.

For Developers the Ansible Role is easy to upload and share via Ansible Galaxy. Plus an Ansible role has a defined standard directory structure and format.

What is Ansible Galaxy?

  • [Ansible Galaxy](https://galaxy.ansible.com/)
  • [lucab85/ansible_role_log4shell](https://galaxy.ansible.com/lucab85/ansible_role_log4shell)

The website is available at the URL https://galaxy.ansible.com/.

The search engine, Tags, and Platform make it easy to find any content inside.

I recommend you carefully evaluate the quality of content before using it in your system.

Quality indicators are usually the quality assurance of code, the supported operating systems and platforms, the documentation, the release numbers, the presence of Changelog, the number of downloads, and the author or creator.

Please notice that the website contains Ansible Roles and Ansible Collections. Today we’re focusing on Ansible Role content.

Links

  • https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse.html
  • https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#using-roles
  • https://galaxy.ansible.com/
  • https://galaxy.ansible.com/lucab85/ansible_role_log4shell

## Playbook

Let’s jump into a real-life How to Download and Use the Ansible Galaxy Role lucab85.ansible_role_log4shell.

code

  • role.yml

``yaml

---

  • name: role Playbook

hosts: all

become: true

roles:

- role: lucab85.ansible_role_log4shell

detector_path: "/var/www"

`

  • requirements.yml

`yaml

---

roles:

- name: lucab85.ansible_role_log4shell

`

execution before download

``bash

$ ansible-playbook -i virtualmachines/demo/inventory galaxy/role.yml

ERROR! the role 'lucab85.ansible_role_log4shell' was not found in /Users/lberton/prj/github/ansible-pilot/galaxy/roles:/Users/lberton/.ansible/roles:/

Read the full tutorial: Download and Use Ansible Galaxy Role - ansible-galaxy and requirements.yml