Skip to content

Instantly share code, notes, and snippets.

View platu's full-sized avatar

Philippe Latu platu

View GitHub Profile
@platu
platu / .gitlab-ci.yml
Created March 24, 2024 18:17
IaC Lab 3 GitLab pipeline
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
cache:
paths:
- .cache/pip
- ansible/
stages:
- Build
@platu
platu / routers_config.yml
Created March 24, 2024 17:42
IaC Lab 3 virtual routers network configuration
---
- name: CONFIGURE ROUTER INTERFACES AND DEFAULT ROUTES
hosts: routers
# Base topology configuration tasks for the three routers
tasks:
- name: APPLY HOSTNAME
cisco.ios.ios_hostname:
config:
hostname: "{{ inventory_hostname }}"
@platu
platu / build_lab_inventory.py
Created March 24, 2024 15:01
IaC Lab 3 Dynamic inventory build python script
#!/usr/bin/env python3
import os
import re
import sys
import yaml
"""
VM launch trace file
@platu
platu / copy_run.yml
Last active March 24, 2024 14:29
IaC Lab 3 Ansible copy and run virtual routers stage playbook
---
- name: COPY MASTER IMAGE AND RUN ROUTERS
hosts: hypervisors
tasks:
- name: COPY MASTER IMAGE TO LAB DIRECTORY
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ ansible_env.HOME }}/vm/{{ lab_name }}/"
mode: "0644"
remote_src: true
@platu
platu / prepare.yml
Last active March 24, 2024 13:33
IaC Lab 3 Ansible prepare stage playbook
---
- 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 / ansible.cfg
Created March 24, 2024 09:11
IaC Lab 3 Ansible configuration file
[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
[persistent_connection]
@platu
platu / bob.yml
Last active March 24, 2024 08:41
IaC Lab 3 host_vars
---
lab_name: iac_lab03
image_name: c8000v-universalk9.17.13.01a
oob_vlan: 28
taps:
- name: tapXX3
vlan_mode: access
tag: "{{ oob_vlan }}"
link: RXXX_mgmt
switch: dsw-host
@platu
platu / hosts.yml
Last active March 24, 2024 08:30
IaC Lab 3 inventory file
---
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 / 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 / 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