Skip to content

Instantly share code, notes, and snippets.

View platu's full-sized avatar

Philippe Latu platu

View GitHub Profile
@platu
platu / add_vlan.yml
Last active March 20, 2024 15:15
IaC Lab01 add network access to in-band VLANs for each VM
---
- name: ADD IN BAND VLAN ACCESS
hosts: vms
become: true
tasks:
- name: CHECK IF SYSTEMD NETDEV FILE EXISTS FOR IN BAND VLAN
ansible.builtin.stat:
path: /etc/systemd/network/30-{{ item.interface_type }}{{ item.interface_id }}.netdev
register: netdev_file
@platu
platu / ansible.cfg
Last active March 19, 2024 15:42
IaC Lab01 repository Ansible configuration file
# config file for Lab 01: Build a new Debian GNU/Linux VM
[defaults]
# Use inventory/ folder files as source
inventory=inventory/
host_key_checking = False # Don't worry about RSA Fingerprints
retry_files_enabled = False # Do not create them
deprecation_warnings = False # Do not show warnings
interpreter_python = /usr/bin/python3
[inventory]
enable_plugins = auto, host_list, yaml, ini, toml, script
@platu
platu / hosts.yml
Last active March 24, 2024 08:27
IaC Lab01 initial Ansible lab inventory
---
hypervisors:
hosts:
bob:
ansible_host: fe80:1c::1%enp0s1
vars:
ansible_ssh_user: "{{ hypervisor_user }}"
ansible_ssh_pass: "{{ hypervisor_pass }}"
ansible_ssh_port: 2222
@platu
platu / pull_customize_run.yml
Last active March 19, 2024 16:17
IaC Lab01 pull from cloud.debian.org and customize VM image
---
- name: PULL AND CUSTOMIZE CLOUD IMAGE
hosts: hypervisors
tasks:
- name: DOWNLOAD DEBIAN CLOUD IMAGE QCOW2 FILE
ansible.builtin.get_url:
url: "https://{{ cloud_url }}"
dest: "{{ ansible_env.HOME }}/vm/{{ lab_name }}/{{ image_name }}"
mode: "0644"
@platu
platu / build_lab_inventory.py
Last active March 19, 2024 15:38
IaC Lab01 build dynamic inventory from VM launch traces
#!/usr/bin/env python3
import os
import re
import sys
import yaml
"""
VM launch trace file
@platu
platu / customize.sh
Created February 28, 2024 15:04
IaC Lab01 customize a VM image for the lab environment with management VRF
#!/bin/bash
# This script customizes a VM image for the lab environment
VM="$1"
shift
USER="$1"
shift
SECRET="$1"
shift
@platu
platu / prepare.yml
Last active March 19, 2024 10:22
IaC Lab01 Ansible playbook for virtualization env and switch port configuration
---
- name: PREPARE LAB ENVIRONMENT
hosts: hypervisors
tasks:
- name: ENSURE SYMLINK TO MASTERS DIRECTORY EXISTS
ansible.builtin.file:
src: /var/cache/kvm/masters
dest: "{{ ansible_env.HOME }}/masters"
state: link
@platu
platu / resize.sh
Last active February 28, 2024 07:44
IaC Lab01 vm image file resize script
#!/bin/bash
# This script resizes $1 VM disk image adding $2 GB to the original size
vm="$1"
shift
size="$1"
if [[ -z ${vm} ]] || [[ -z ${size} ]]; then
echo "Usage: $0 <vm> <size>"
@platu
platu / lab14+ansible+iosxe.md
Last active February 19, 2024 15:37
DevNet Lab 14 – Use Ansible to Back Up and Configure a Router
tags
m1, devnet, cisco, linux, lab14

DevNet Lab 14 -- Use Ansible to Back Up and Configure a Router

[toc]


Background / Scenario

@platu
platu / lab15+ansible+incus.md
Last active February 20, 2024 10:03
Using Ansible to automate the installation of Web servers on Incus system containers
tags
m1, Devnet, incus, linux, lab15

DevNet Lab 15 -- Using Ansible to automate the installation of Web servers on Incus system containers

[toc]


Background / Scenario