tags |
---|
m1, devnet, cisco, linux, lab14 |
[toc]
--- | |
- 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 |
# 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 |
--- | |
hypervisors: | |
hosts: | |
bob: | |
ansible_host: fe80:1c::1%enp0s1 | |
vars: | |
ansible_ssh_user: "{{ hypervisor_user }}" | |
ansible_ssh_pass: "{{ hypervisor_pass }}" | |
ansible_ssh_port: 2222 |
--- | |
- 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" |
#!/usr/bin/env python3 | |
import os | |
import re | |
import sys | |
import yaml | |
""" | |
VM launch trace file |
#!/bin/bash | |
# This script customizes a VM image for the lab environment | |
VM="$1" | |
shift | |
USER="$1" | |
shift | |
SECRET="$1" | |
shift |
--- | |
- 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 |
#!/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>" |