Initial hyper-v demo skeleton

This commit is contained in:
2026-04-28 15:59:50 -04:00
commit 1759682aef
14 changed files with 737 additions and 0 deletions

43
playbooks/install-iis.yml Normal file
View File

@@ -0,0 +1,43 @@
---
- name: Install and configure IIS
hosts: web_servers
gather_facts: true
tasks:
- name: Install IIS features
ansible.windows.win_feature:
name: "{{ iis_features }}"
state: present
register: iis_install
- name: Reboot if required
ansible.windows.win_reboot:
reboot_timeout: 3600
when: iis_install.reboot_required
- name: Create demo web content
ansible.windows.win_copy:
content: |
<!DOCTYPE html>
<html>
<head>
<title>Demo IIS Site - {{ inventory_hostname }}</title>
</head>
<body>
<h1>Welcome to {{ inventory_hostname }}</h1>
<p>This server was configured by Ansible Automation Platform</p>
<p>Deployment Date: {{ ansible_date_time.iso8601 }}</p>
</body>
</html>
dest: "{{ iis_website_path }}\\index.html"
- name: Ensure IIS service is running
ansible.windows.win_service:
name: W3SVC
state: started
start_mode: auto
- name: Update CMDB with IIS installation
ansible.builtin.debug:
msg: "Would update ServiceNow CMDB with IIS installation"
# TODO: Implement ServiceNow CMDB update

29
playbooks/patch-vms.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- name: Patch Windows Servers
hosts: windows_servers
gather_facts: true
tasks:
- name: Search for Windows updates
ansible.windows.win_updates:
category_names: "{{ windows_update_categories }}"
state: searched
register: update_search
- name: Display available updates
ansible.builtin.debug:
msg: "{{ update_search.found_update_count }} updates available"
- name: Install Windows updates
ansible.windows.win_updates:
category_names: "{{ windows_update_categories }}"
state: installed
reboot: true
reboot_timeout: 3600
when: update_search.found_update_count > 0
register: update_result
- name: Update CMDB with patch status
ansible.builtin.debug:
msg: "Would update ServiceNow CMDB with patch status"
# TODO: Implement ServiceNow CMDB update

View File

@@ -0,0 +1,25 @@
---
- name: Provision Windows Server VM on Hyper-V
hosts: hyperv_hosts
gather_facts: false
vars_prompt:
- name: vm_name
prompt: "Enter VM name"
private: false
- name: vm_ip_address
prompt: "Enter IP address for VM"
private: false
tasks:
- name: Placeholder - Create VM
ansible.builtin.debug:
msg: "Will create VM {{ vm_name }} with IP {{ vm_ip_address }}"
# TODO: Implement VM creation using hyper-v modules
# TODO: Generate autounattend.xml from template
# TODO: Attach autounattend.xml to VM
# TODO: Start VM and wait for provisioning
# TODO: Add VM to inventory
# TODO: Update ServiceNow CMDB

39
playbooks/sync-cmdb.yml Normal file
View File

@@ -0,0 +1,39 @@
---
- name: Synchronize VM information to ServiceNow CMDB
hosts: windows_servers
gather_facts: true
tasks:
- name: Gather Windows facts
ansible.builtin.setup:
gather_subset:
- hardware
- network
- virtual
- name: Prepare CMDB data
ansible.builtin.set_fact:
cmdb_data:
name: "{{ inventory_hostname }}"
ip_address: "{{ ansible_ip_addresses[0] | default('') }}"
os: "{{ ansible_os_family }}"
os_version: "{{ ansible_distribution_version }}"
cpu_count: "{{ ansible_processor_vcpus }}"
ram: "{{ ansible_memtotal_mb }}"
managed_by: "{{ managed_by }}"
environment: "{{ environment }}"
- name: Display CMDB data
ansible.builtin.debug:
var: cmdb_data
# TODO: Implement actual ServiceNow CMDB update using servicenow.itsm collection
# - name: Update ServiceNow CMDB
# servicenow.itsm.configuration_item:
# instance:
# host: "{{ servicenow_instance }}"
# username: "{{ servicenow_username }}"
# password: "{{ servicenow_password }}"
# state: present
# sys_class_name: "{{ servicenow_table }}"
# data: "{{ cmdb_data }}"