Introduction

Automation is a powerful tool in modern IT and infrastructure management, and Ansible is at the forefront of this revolution. When working with Ansible roles, ensuring that your metadata is structured correctly is essential. Ansible Rule 704, "meta-video-links," focuses on the proper formatting of video links in your role's metadata. It enforces the use of dictionaries for items in the meta/main.yml file and ensures that video links follow a specific format.

The Importance of Role Metadata

Roles are a fundamental concept in Ansible, allowing you to encapsulate a set of tasks, variables, and templates into reusable automation logic. Metadata is an integral part of roles, providing information about the role, such as its purpose and authorship.

Understanding Rule 704

Rule 704, "meta-video-links," checks the formatting of video links in the metadata of Ansible roles.

In particular, it enforces the use of dictionaries for items in the video_links section of your role's metadata. Each item in the video_links section should have two keys:

1. url: This key should contain a shared link from platforms like YouTube, Vimeo, or Google Drive.

2. title: This key should provide a title for the video link.

Let's explore why adhering to this rule is crucial.

Problematic Code vs. Correct Code

To understand the rule better, let's compare problematic code that violates Rule 704 with the correct code that adheres to the rule's recommendations.

Problematic Code

``yaml

---

galaxy_info:

video_links:

- https://www.youtube.com/@AnsiblePilot/ # Does not use the url key.

- my_bad_key: https://www.youtube.com/@AnsiblePilot/ # Uses an unsupported key.

title: Incorrect key.

- url: www.acme.com/vid # Uses an unsupported URL format.

title: Incorrect URL format.

`

Output:

`bash

WARNING Listing 4 violation(s) that are fatal

meta-video-links: Expected item in 'video_links' to be a dictionary

role704/meta/main.yml:1

meta-video-links: Expected item in 'video_links' to contain only keys 'url' and 'title'

role704/meta/main.yml:1

meta-video-links: URL format 'www.acme.com/vid' is not recognized. Expected it be a shared link from Vimeo, YouTube, or Google Drive.

role704/meta/main.yml:1

schema[meta]: $.galaxy_info 'author' is a required property. See https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#using-role-dependencies

role704/meta/main.yml:1 Returned errors will not include exact line numbers, but they will mention

the schema name being used as a tag, like schema[playbook],

schema[tasks].

This rule is not skippable and stops further processing of the file.

If incorrect schema was picked, you might want to either:

* move the file to standard location, so its file is detected correctly.

* use kinds:` option in linter config to help it pick correct file type.

Read documentation for instructions on how to ignore specific rule violations.