SHARE
TWEET

windows-server.yaml

dev-rowbot Jun 7th, 2017 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. heat_template_version: 2017-02-24
  2.  
  3. description: Template that installs Windows Server
  4.  
  5. parameters:
  6.   image:
  7.     type: string
  8.     label: Image name or ID
  9.     description: Image to be used for server
  10.     default: 'windows 2012r2 cloud'
  11.     constraints:
  12.       - allowed_values:
  13.        - 'windows 2012r2 cloud'
  14.   public_net:
  15.     type: string
  16.     description: >
  17.      ID or name of public network for which floating IP addresses will be allocated
  18.   windows_server_network:
  19.     type: string
  20.     description: Name of private network to be created
  21.   windows_server_subnet:
  22.     type: string
  23.     description: Subnet details
  24.   windows_server_hostname:
  25.     type: string
  26.     description: Server HOSTNAME
  27.  
  28. resources:
  29.  # Generate a random 16 Character Hex String
  30.   random_volume_name:
  31.     type: OS::Heat::RandomString
  32.     properties:
  33.       length: 16
  34.       sequence: hexdigits
  35.  
  36.   windows_server_volume:
  37.     type: OS::Cinder::Volume
  38.     properties:
  39.       name:
  40.         list_join: ['-', [ {get_param: windows_server_hostname}, { get_resource: random_volume_name}]]
  41.       image: { get_param: image }
  42.       size: 45
  43.       volume_type: unity_cap
  44.  
  45.   windows_server:
  46.     type: OS::Nova::Server
  47.     depends_on: windows_server_volume
  48.     properties:
  49.       name: { get_param: windows_server_hostname }
  50.       image: { get_param: image }
  51.       flavor: m1.medium
  52.       block_device_mapping: [{ device_name: "vda", volume_id : { get_resource : windows_server_volume }, delete_on_termination : "true" }]
  53.       key_name: 'windows-cloudinit'
  54.       networks:
  55.         - port: { get_resource: windows_server_port }
  56.       user_data_format: RAW
  57.       user_data:
  58.         str_replace:
  59.           template: |
  60.            #ps1_sysnative
  61.  
  62.             $ComputerName = Hostname
  63.             $DomainName = "param_domain_name"
  64.             $OUPath = "param_ad_ou_path"
  65.             $username = "$DomainName\param_user_name"
  66.             $password = "param_user_password" | ConvertTo-SecureString -asPlainText -Force
  67.             $Credential = New-Object System.Management.Automation.PSCredential($username,$password)
  68.  
  69.             # To force a restart, add "-Restart -Force" to the end of this command
  70.             Add-Computer -ComputerName $ComputerName -DomainName $DomainName -Credential $Credential -LocalCredential $Credential #-OUPath $OUPath
  71.  
  72.             # Cloudbase-Init Exit codes:
  73.             # 1001 - reboot and don’t run the plugin again on next boot
  74.             # 1002 - don’t reboot now and run the plugin again on next boot
  75.             # 1003 - reboot and run the plugin again on next boot
  76.  
  77.             exit 1001
  78.           params:
  79.             param_domain_name: mydomain.com
  80.             param_user_name: domainusername
  81.             param_user_password: domuserpassword
  82.             param_ad_ou_path: "OU=testOU,DC=domain,DC=Domain,DC=com"
  83.  
  84.   windows_server_port:
  85.     type: OS::Neutron::Port
  86.     properties:
  87.       network_id: { get_param: windows_server_network }
  88.       fixed_ips:
  89.         - subnet_id: { get_param: windows_server_subnet }
  90.  
  91.   windows_server_floating_ip:
  92.     type: OS::Neutron::FloatingIP
  93.     properties:
  94.       floating_network: { get_param: public_net }
  95.       port_id: { get_resource: windows_server_port }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top