first commit

This commit is contained in:
root
2024-07-12 12:58:40 +02:00
commit 30fdad3be5
557 changed files with 11142 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@@ -0,0 +1,3 @@
---
# defaults file for azure-createwindowsvm
vmsize: Standard_DS1_v2

View File

@@ -0,0 +1,2 @@
---
# handlers file for azure-createwindowsvm

View File

@@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@@ -0,0 +1,123 @@
---
# tasks file for azure-createwindowsvm
# - name: Create public IP address
# azure_rm_publicipaddress:
# resource_group: "{{RG_name}}"
# allocation_method: Static
# name: "{{hostname}}-pip"
# register: output_ip_address
# - name: Output public IP
# debug:
# msg: "The public IP is {{ output_ip_address.state.ip_address }}"
- name: Get facts for one resource group
azure_rm_resourcegroup_info:
name: "{{RG_name}}"
register: rginfo
- name: Create a network interface
azure_rm_networkinterface:
name: "{{hostname}}-nic"
resource_group: "{{RG_name}}"
location: westeurope
virtual_network: "/subscriptions/dd4dbc55-c970-4a1f-8ddd-8cb7ae7900dd/resourceGroups/rg-network-tst-01/providers/Microsoft.Network/virtualNetworks/vnet-awe-tst-01"
subnet_name: "{{subnetname}}"
enable_accelerated_networking: True
security_group: "/subscriptions/dd4dbc55-c970-4a1f-8ddd-8cb7ae7900dd/resourceGroups/rg-network-tst-01/providers/Microsoft.Network/networkSecurityGroups/nsg-tst-01-green"
ip_configurations:
- name: default
# public_ip_address_name: "{{hostname}}-pip"
primary: True
register: new_nic
- name: Get private IP of NIC
azure_rm_networkinterface_info:
resource_group: "{{RG_name}}"
name: "{{hostname}}-nic"
register: nic_info
- name: Display private IP of NIC
debug:
var: "nic_info.networkinterfaces[0].ip_configurations[0].private_ip_address"
- name: Create VM
azure_rm_virtualmachine:
resource_group: "{{RG_name}}"
name: "{{hostname}}"
vm_size: "{{vmsize}}"
admin_username: ApeAdmin
admin_password: "{{ password }}"
network_interfaces: "{{hostname}}-nic"
os_type: Windows
boot_diagnostics:
enabled: false
managed_disk_type: "Premium_LRS"
os_disk_name: "{{hostname}}-osdisk"
os_disk_size_gb: 128
image:
offer: WindowsServer
publisher: MicrosoftWindowsServer
sku: "{{win_sku}}"
version: latest
tags:
Dexcare: "{{tag_dexcare}}"
ApplicationITContact: "{{tag_ApplicationITContact}}"
DexMach_Protection: "ManagedByOther"
Schedule: "{{tag_Schedule}}"
ServiceHours: "{{tag_ServiceHours}}"
Criticality: "{{tag_Criticality}}"
UpdateSchedule: "{{tag_UpdateSchedule}}"
TeamSpecialist: "{{tag_TeamSpecialist}}"
no_log: false
# - name: Create VM script extension to enable HTTPS WinRM listener
# azure_rm_virtualmachineextension:
# name: winrm-extension
# resource_group: "{{RG_name}}"
# virtual_machine_name: "{{hostname}}"
# publisher: Microsoft.Compute
# virtual_machine_extension_type: CustomScriptExtension
# type_handler_version: '1.9'
# settings: '{"fileUris": ["https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"],"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"}'
# auto_upgrade_minor_version: true
- name: Enable winrm
azure_rm_virtualmachineextension:
name: winrm-extension
resource_group: "{{RG_name}}"
virtual_machine_name: "{{hostname}}"
publisher: Microsoft.Compute
virtual_machine_extension_type: CustomScriptExtension
type_handler_version: '1.9'
settings: '{"commandToExecute": "powershell winrm quickconfig -force"}'
auto_upgrade_minor_version: true
- name: Open port
azure_rm_virtualmachineextension:
name: winrm-extension
resource_group: "{{RG_name}}"
virtual_machine_name: "{{hostname}}"
publisher: Microsoft.Compute
virtual_machine_extension_type: CustomScriptExtension
type_handler_version: '1.9'
settings: {"commandToExecute": "powershell New-NetFirewallRule -DisplayName 'Winrm' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 5985"}
auto_upgrade_minor_version: true
# - name: Get facts for one Public IP
# azure_rm_publicipaddress_info:
# resource_group: "{{RG_name}}"
# name: "{{hostname}}-pip"
# register: publicipaddresses
# - name: set public ip address fact
# set_fact: publicipaddress="{{ publicipaddresses | json_query('publicipaddresses[0].ip_address')}}"
- name: wait for the WinRM port to come online
wait_for:
port: 5985
host: "{{nic_info.networkinterfaces[0].ip_configurations[0].private_ip_address}}"
timeout: 6

View File

@@ -0,0 +1,2 @@
localhost

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- azure-createwindowsvm

View File

@@ -0,0 +1,2 @@
---
# vars file for azure-createwindowsvm