https://github.com/Lenniusce/Network-Automation

TechnologyInfo
Ansible VM192.168.161.128/24
Netbox VM192.168.161.129/24
R730/EV-NG192.168.0.161/24
GithubWeb
VSCodeUsing Remote SSH to develop on Ansible VM

Intro


As a follow-on from my last post, I am building on BPG VXLAN EVPN datacenter scripts and moving them to be deployed using Ansible and jinja templates. Right Now I have them “building” through templates, but not deploying to devices yet.

I already have the configs available, but will be converting them to .j2 templates. The “generate-configs” playbook is functional, but look for future posts for updates as I get further along.

  • Source of Truth:Netbox using live inventory
  • Deployment method: Ansible
  • Virtualiation for Devices: EVE-NG

Get Environment Started

Before getting started, make sure both virtual machines are up and running:

  • Start the NetBox VM (Ubuntu 22.04.4 LTS)
  • Start the Ansible VM (Ubuntu 22.04.4 LTS)

Connect to the Ansible VM

Use VS Code’s Remote SSH feature to connect:

  • Open VS Code
  • Connect to the Ansible VM using Remote SSH

Configure Python with pyenv

Once you’re connected to the Ansible VM, set up the correct Python version:

Navigate to your project directory:

cd network-automation/ansible

Set the local Python version using pyenv:

pyenv local 3.12.3

Reload your shell to apply changes:

source ~/.bashrc

Verify the Python version:

python3 --version

If you want to confirm your pyenv setup:

pyenv prefiX

Test out connection from Ansible to Netbox

curl -H "Authorization: Token REDACTED" http://192.168.161.128:8000/api/status/

If it doesnt work make sure the tokens are set:

export NETBOX_API=<YOUR_NETBOX_URL> (note - must include http:// or https://) export NETBOX_TOKEN=<YOUR_NETBOX_API_TOKEN>

Run these to see if inventory shows:

ansible-inventory -i inventories/netbox_inv.yml --list
ansible-inventory -i inventories/netbox_inv.yml --graph

Run the generate-configs from ansible folder

  ansible-playbook -i inventories/netbox_inv.yml ~/Network-Automation/ansible/playbooks/write-configs/generate-configs.yml

You will then see configuration files generate under the folder after each task runs:

Each new rendition of the file appears.



Appendix:

Netbox VM PIP:

  • attrs==23.2.0
  • Automat==22.10.0
  • Babel==2.10.3
  • bcc==0.29.1
  • bcrypt==3.2.2
  • blinker==1.7.0
  • certifi==2023.11.17
  • chardet==5.2.0
  • click==8.1.6
  • cloud-init==25.1.4
  • colorama==0.4.6
  • command-not-found==0.3
  • configobj==5.0.8
  • constantly==23.10.4
  • cryptography==41.0.7
  • dbus-python==1.3.2
  • distro==1.9.0
  • distro-info==1.7+build1
  • httplib2==0.20.4
  • hyperlink==21.0.0
  • idna==3.6
  • incremental==22.10.0
  • Jinja2==3.1.2
  • jsonpatch==1.32
  • jsonpointer==2.0
  • jsonschema==4.10.3
  • launchpadlib==1.11.0
  • lazr.restfulclient==0.14.6
  • lazr.uri==1.0.6
  • markdown-it-py==3.0.0
  • MarkupSafe==2.1.5
  • mdurl==0.1.2
  • netaddr==0.8.0
  • netifaces==0.11.0
  • oauthlib==3.2.2
  • pexpect==4.9.0
  • ptyprocess==0.7.0
  • pyasn1==0.4.8
  • pyasn1-modules==0.2.8
  • Pygments==2.17.2
  • PyGObject==3.48.2
  • PyHamcrest==2.1.0
  • PyJWT==2.7.0
  • pyOpenSSL==23.2.0
  • pyparsing==3.1.1
  • pyrsistent==0.20.0
  • pyserial==3.5
  • python-apt==2.7.7+ubuntu5.1
  • python-debian==0.1.49+ubuntu2
  • python-magic==0.4.27
  • pytz==2024.1
  • PyYAML==6.0.1
  • requests==2.31.0
  • rich==13.7.1
  • service-identity==24.1.0
  • setuptools==68.1.2
  • six==1.16.0
  • sos==4.5.6
  • ssh-import-id==5.11
  • systemd-python==235
  • Twisted==24.3.0
  • ubuntu-drivers-common==0.0.0
  • ubuntu-pro-client==8001
  • ufw==0.36.2
  • unattended-upgrades==0.1
  • urllib3==2.0.7
  • wadllib==1.3.6
  • wheel==0.42.0
  • xkit==0.0.0
  • zope.interface==6.1

Ansible VM PIP

  • ansible==13.4.0
  • ansible-core==2.20.3
  • certifi==2026.2.25
  • cffi==2.0.0
  • charset-normalizer==3.4.6
  • cryptography==46.0.5
  • idna==3.11
  • Jinja2==3.1.6
  • MarkupSafe==3.0.3
  • packaging==26.0
  • pycparser==3.0
  • pynetbox==7.6.1
  • pytz==2026.1.post1
  • PyYAML==6.0.3
  • requests==2.32.5
  • resolvelib==1.2.1
  • urllib3==2.6.3

Leave a comment

Trending