|
1 | 1 | # Packer Azure Windows Image |
2 | 2 |
|
3 | | -Example of how to create and deploy Azure Windows VM with preinstalled chocolatey and other software |
4 | | - |
5 | | -### To install Packer |
6 | | - |
7 | | -- `choco install packer -y` |
8 | | - |
9 | | -### Packer commands |
10 | | - |
11 | | -- `packer init windows-server2019-v1.pkr.hcl` |
12 | | -- `packer validate -var-file="windows.variables.json" windows-server2019-v1.pkr.hcl` |
13 | | -- `packer build -var-file="windows.variables.json" windows-server2019-v1.pkr.hcl` |
14 | | - |
15 | | -## Pre-commit configuration |
16 | | - |
17 | | -- Install python3 via windows store |
18 | | -- `pip install --upgrade pip` |
19 | | -- `pip install pre-commit` |
20 | | -- Update PATH variable |
21 | | -- `pre-commit install` |
22 | | - |
23 | | -## Install terraform docs |
24 | | - |
25 | | -- `choco install terraform-docs` |
26 | | - |
27 | | -## Install tflint |
28 | | - |
29 | | -- `choco install tflint` |
30 | | - |
31 | | -## Documentation |
32 | | - |
33 | | -- https://github.com/antonbabenko/pre-commit-terraform |
34 | | -- https://github.com/kolosovpetro/AzureTerraformBackend |
35 | | -- https://github.com/terraform-docs/terraform-docs |
36 | | -- https://terraform-docs.io/user-guide/installation/ |
37 | | -- https://pre-commit.com/ |
38 | | - |
39 | | -## Storage account configuration file |
40 | | - |
41 | | -```bash |
42 | | -storage_account_name = "storage_account_name" |
43 | | -container_name = "container_name" |
44 | | -key = "terraform.tfstate" |
45 | | -sas_token = "sas_token" |
46 | | -``` |
47 | | - |
48 | | -## Deploy storage account for terraform state |
49 | | - |
50 | | -- See [CreateAzureStorageAccount.ps1](./CreateAzureStorageAccount.ps1) |
51 | | - |
52 | | -# Module documentation |
53 | | - |
54 | | -<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
55 | | -## Requirements |
56 | | - |
57 | | -| Name | Version | |
58 | | -|------|---------| |
59 | | -| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | =3.71.0 | |
60 | | - |
61 | | -## Providers |
62 | | - |
63 | | -| Name | Version | |
64 | | -|------|---------| |
65 | | -| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.71.0 | |
66 | | - |
67 | | -## Modules |
68 | | - |
69 | | -| Name | Source | Version | |
70 | | -|------|--------|---------| |
71 | | -| <a name="module_custom_script_extension"></a> [custom\_script\_extension](#module\_custom\_script\_extension) | ./modules/custom-script-extension | n/a | |
72 | | -| <a name="module_key_vault"></a> [key\_vault](#module\_key\_vault) | ./modules/keyvault | n/a | |
73 | | -| <a name="module_key_vault_secrets"></a> [key\_vault\_secrets](#module\_key\_vault\_secrets) | ./modules/keyvault-secrets | n/a | |
74 | | -| <a name="module_keyvault_access_policy"></a> [keyvault\_access\_policy](#module\_keyvault\_access\_policy) | ./modules/keyvault-access-policy | n/a | |
75 | | -| <a name="module_network"></a> [network](#module\_network) | ./modules/network | n/a | |
76 | | -| <a name="module_storage"></a> [storage](#module\_storage) | ./modules/storage | n/a | |
77 | | -| <a name="module_virtual_machine"></a> [virtual\_machine](#module\_virtual\_machine) | ./modules/vm | n/a | |
78 | | - |
79 | | -## Resources |
80 | | - |
81 | | -| Name | Type | |
82 | | -|------|------| |
83 | | -| [azurerm_resource_group.public](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/resource_group) | resource | |
84 | | -| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/data-sources/client_config) | data source | |
85 | | - |
86 | | -## Inputs |
87 | | - |
88 | | -| Name | Description | Type | Default | Required | |
89 | | -|------|-------------|------|---------|:--------:| |
90 | | -| <a name="input_azure-client-id"></a> [azure-client-id](#input\_azure-client-id) | n/a | `string` | n/a | yes | |
91 | | -| <a name="input_azure-client-secret"></a> [azure-client-secret](#input\_azure-client-secret) | n/a | `string` | n/a | yes | |
92 | | -| <a name="input_azure-region"></a> [azure-region](#input\_azure-region) | n/a | `string` | n/a | yes | |
93 | | -| <a name="input_azure-resource-group"></a> [azure-resource-group](#input\_azure-resource-group) | n/a | `string` | n/a | yes | |
94 | | -| <a name="input_azure-subscription-id"></a> [azure-subscription-id](#input\_azure-subscription-id) | n/a | `string` | n/a | yes | |
95 | | -| <a name="input_azure-tenant-id"></a> [azure-tenant-id](#input\_azure-tenant-id) | n/a | `string` | n/a | yes | |
96 | | -| <a name="input_custom_script_extension_enabled"></a> [custom\_script\_extension\_enabled](#input\_custom\_script\_extension\_enabled) | Specifies whether the extension should be enabled or disabled. | `bool` | n/a | yes | |
97 | | -| <a name="input_image-name"></a> [image-name](#input\_image-name) | n/a | `string` | n/a | yes | |
98 | | -| <a name="input_image_resource_group_name"></a> [image\_resource\_group\_name](#input\_image\_resource\_group\_name) | Specifies the name of the resource group that contains the image to use to create the virtual machine. | `string` | n/a | yes | |
99 | | -| <a name="input_os_profile_admin_password"></a> [os\_profile\_admin\_password](#input\_os\_profile\_admin\_password) | Specifies the password of the administrator account. | `string` | n/a | yes | |
100 | | -| <a name="input_os_profile_admin_username"></a> [os\_profile\_admin\_username](#input\_os\_profile\_admin\_username) | Specifies the name of the administrator account. | `string` | n/a | yes | |
101 | | -| <a name="input_prefix"></a> [prefix](#input\_prefix) | Resources name prefix | `string` | n/a | yes | |
102 | | -| <a name="input_resource_group_location"></a> [resource\_group\_location](#input\_resource\_group\_location) | Location of the resource group. | `string` | n/a | yes | |
103 | | -| <a name="input_storage_account_replication"></a> [storage\_account\_replication](#input\_storage\_account\_replication) | Specifies the replication type for this storage account. | `string` | n/a | yes | |
104 | | -| <a name="input_storage_account_tier"></a> [storage\_account\_tier](#input\_storage\_account\_tier) | Specifies the tier to use for this storage account. | `string` | n/a | yes | |
105 | | -| <a name="input_storage_image_reference_offer"></a> [storage\_image\_reference\_offer](#input\_storage\_image\_reference\_offer) | Specifies the offer of the platform image or marketplace image used to create the virtual machine. | `string` | n/a | yes | |
106 | | -| <a name="input_storage_image_reference_publisher"></a> [storage\_image\_reference\_publisher](#input\_storage\_image\_reference\_publisher) | The publisher of the image used to create the virtual machine. | `string` | n/a | yes | |
107 | | -| <a name="input_storage_image_reference_sku"></a> [storage\_image\_reference\_sku](#input\_storage\_image\_reference\_sku) | Specifies the SKU of the platform image or marketplace image used to create the virtual machine. | `string` | n/a | yes | |
108 | | -| <a name="input_storage_image_reference_version"></a> [storage\_image\_reference\_version](#input\_storage\_image\_reference\_version) | Specifies the version of the platform image or marketplace image used to create the virtual machine. | `string` | n/a | yes | |
109 | | -| <a name="input_storage_os_disk_caching"></a> [storage\_os\_disk\_caching](#input\_storage\_os\_disk\_caching) | Specifies the caching requirements for the OS disk. | `string` | n/a | yes | |
110 | | -| <a name="input_storage_os_disk_create_option"></a> [storage\_os\_disk\_create\_option](#input\_storage\_os\_disk\_create\_option) | Specifies how the virtual machine should be created. | `string` | n/a | yes | |
111 | | -| <a name="input_storage_os_disk_managed_disk_type"></a> [storage\_os\_disk\_managed\_disk\_type](#input\_storage\_os\_disk\_managed\_disk\_type) | Specifies the storage account type for the managed disk. | `string` | n/a | yes | |
112 | | -| <a name="input_vm-size"></a> [vm-size](#input\_vm-size) | n/a | `string` | n/a | yes | |
113 | | -| <a name="input_vm_size"></a> [vm\_size](#input\_vm\_size) | The size of the virtual machine. | `string` | n/a | yes | |
114 | | - |
115 | | -## Outputs |
116 | | - |
117 | | -| Name | Description | |
118 | | -|------|-------------| |
119 | | -| <a name="output_public_ip"></a> [public\_ip](#output\_public\_ip) | n/a | |
120 | | -| <a name="output_username"></a> [username](#output\_username) | n/a | |
121 | | -<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 3 | +Packer-based automation for building Azure Windows Server images. Supports Windows Server 2019 & 2022 with pre-installed |
| 4 | +tools like Azure CLI, PowerShell Core, and SQL Server Management Studio. Ensures integrity with scf scan & DISM, |
| 5 | +configures WinRM for Ansible, and validates images with Terraform. |
| 6 | + |
| 7 | +## Provisioners used |
| 8 | + |
| 9 | +- https://github.com/hashicorp/packer-plugin-azure |
| 10 | +- https://github.com/rgl/packer-plugin-windows-update |
| 11 | + |
| 12 | +## Installed software v4 |
| 13 | + |
| 14 | +- azure-cli |
| 15 | +- microsoft-edge |
| 16 | +- git |
| 17 | +- netfx-4.8-devpack |
| 18 | +- dotnet-6.0-sdk |
| 19 | +- powershell-core |
| 20 | +- winrar |
| 21 | +- notepadplusplus |
| 22 | +- sql-server-management-studio |
| 23 | +- azcopy10 |
| 24 | + |
| 25 | +## Terraform modules in this repository |
| 26 | + |
| 27 | +- custom-script-extension |
| 28 | +- vm |
| 29 | +- storage |
| 30 | +- network |
| 31 | +- keyvault-secrets |
| 32 | +- keyvault-access-policy |
| 33 | +- keyvault |
0 commit comments