Skip to content

Instantly share code, notes, and snippets.

@hamptonmoore
Last active June 20, 2023 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamptonmoore/1972001d3222f3e7742e87ec489447b8 to your computer and use it in GitHub Desktop.
Save hamptonmoore/1972001d3222f3e7742e87ec489447b8 to your computer and use it in GitHub Desktop.

Hammy's Guide to Contributing with AVD

The information that follows represents knowledge that I wish I had when first contributing to the project. Keep in mind that this guide may not be applicable to your environment, and it should not be considered a comprehensive tutorial for the dev-env installation, nor a walkthrough. While many of these issues and fixes might seem obvious, when beginning contributions to a new project there is a lot of new information to absorb and systems to figure out, I figure the easier some steps are the better.

Installation: Navigating Python Package Management

If your Python environment resembles mine, it likely contains a myriad of randomly installed packages, with multiple Python versions and environments set up. In this context, I found pipenv to be the most straightforward tool. A simple pipenv install --python 3.11 command sets up the required Python environment in the AVD folder, followed by pipenv shell. After this, I configured VSCode to use the Python environment that pipenv established as my default interpreter, making sure all terminal sessions were in this env.

Environment Variable: ANSIBLE_COLLECTIONS_PATHS

Setting the relevant Ansible collections path allows you to use ansible_collections without the necessity to rebuild the collection. Here's the command I used: ANSIBLE_COLLECTIONS_PATHS="/Users/hampton/Documents/repos/avd/arista-ansible/ansible-avd/ansible_collections:/Users/hampton/.ansible/collections/ansible_collections/". One can always just configure the ansible.cfg file to change the collections path system/user wide if they desire

Make sure to install pre-commit hooks

Title explains https://avd.sh/en/stable/docs/contribution/development.html#pre-commit-hook

Where should schema changes be?

The large schema yaml and json files for both eos_designs and eos_cli_config_gen are built using the various schema files in their respective schema_fragements/ directory. Changes to the combined schema files will be discarded if they are sourced from the smaller fragment files. Rebuilding of the schema based on the fragments is done with ansible-playbook playbooks/_build_schemas_and_docs.yml, but will also be performed by the pre-commit job.

Is the Schema Build Not Updating?

While running ansible-playbook playbooks/_build_schemas_and_docs.yml, I encountered a problem: the eos_designs.schema.yml and relevant docs were not updating, and no error messages were provided. The root cause of this problem is that it modifies the schema where the collection is installed. Thus, ensure that you're using the ANSIBLE_COLLECTIONS_PATHS environment variable, or that you've updated the ansible.cfg file so that it uses your local collection.

Look at previous changes to figure out what files contribute to what

The AVD repo is quite large with many moving pieces. I found that looking at small feature commits leads to the ability to quickly find the relevent files and reason through how those changes work. For example

Implementing molecule tests

When making a molecule test that needs a need host I like to start out by making that test without the feature I am implementing. I will then commit that base config to git, this will make it so that any of the config changes one is making are easy to differentiate since it'll be the only text added to that new file as opposed to the whole file being new like before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment