1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3 4# Copyright: (c) 2015, Henrik Wallström <henrik@wallstroms.nu> 5# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 7DOCUMENTATION = r''' 8--- 9module: win_iis_website 10short_description: Configures a IIS Web site 11description: 12 - Creates, Removes and configures a IIS Web site. 13options: 14 name: 15 description: 16 - Names of web site. 17 type: str 18 required: yes 19 site_id: 20 description: 21 - Explicitly set the IIS numeric ID for a site. 22 - Note that this value cannot be changed after the website has been created. 23 type: str 24 state: 25 description: 26 - State of the web site 27 type: str 28 choices: [ absent, started, stopped, restarted ] 29 physical_path: 30 description: 31 - The physical path on the remote host to use for the new site. 32 - The specified folder must already exist. 33 type: str 34 application_pool: 35 description: 36 - The application pool in which the new site executes. 37 type: str 38 port: 39 description: 40 - The port to bind to / use for the new site. 41 type: int 42 ip: 43 description: 44 - The IP address to bind to / use for the new site. 45 type: str 46 hostname: 47 description: 48 - The host header to bind to / use for the new site. 49 type: str 50 parameters: 51 description: 52 - Custom site Parameters from string where properties are separated by a pipe and property name/values by colon Ex. "foo:1|bar:2" 53 - Some custom parameters that you can use are listed below, this isn't a definitive list but some common parameters. 54 - C(logfile.directory) - Physical path to store Logs, e.g. C(D:\IIS-LOGs\). 55 - C(logfile.period) - Log file rollover scheduled accepting these values, how frequently the log file should be rolled-over, 56 e.g. C(Hourly, Daily, Weekly, Monthly). 57 - C(logfile.LogFormat) - Log file format, by default IIS uses C(W3C). 58 - C(logfile.truncateSize) - The size at which the log file contents will be trunsted, expressed in bytes. 59 type: str 60seealso: 61- module: community.windows.win_iis_virtualdirectory 62- module: community.windows.win_iis_webapplication 63- module: community.windows.win_iis_webapppool 64- module: community.windows.win_iis_webbinding 65author: 66- Henrik Wallström (@henrikwallstrom) 67''' 68 69EXAMPLES = r''' 70 71# Start a website 72 73- name: Acme IIS site 74 community.windows.win_iis_website: 75 name: Acme 76 state: started 77 port: 80 78 ip: 127.0.0.1 79 hostname: acme.local 80 application_pool: acme 81 physical_path: C:\sites\acme 82 parameters: logfile.directory:C:\sites\logs 83 register: website 84 85# Remove Default Web Site and the standard port 80 binding 86- name: Remove Default Web Site 87 community.windows.win_iis_website: 88 name: "Default Web Site" 89 state: absent 90 91# Create a WebSite with custom Logging configuration (Logs Location, Format and Rolling Over). 92 93- name: Creating WebSite with Custom Log location, Format 3WC and rolling over every hour. 94 community.windows.win_iis_website: 95 name: MyCustom_Web_Shop_Site 96 state: started 97 port: 80 98 ip: '*' 99 hostname: '*' 100 physical_path: D:\wwwroot\websites\my-shop-site 101 parameters: logfile.directory:D:\IIS-LOGS\websites\my-shop-site|logfile.period:Hourly|logFile.logFormat:W3C 102 application_pool: my-shop-site 103 104# Some commandline examples: 105 106# This return information about an existing host 107# $ ansible -i vagrant-inventory -m community.windows.win_iis_website -a "name='Default Web Site'" window 108# host | success >> { 109# "changed": false, 110# "site": { 111# "ApplicationPool": "DefaultAppPool", 112# "Bindings": [ 113# "*:80:" 114# ], 115# "ID": 1, 116# "Name": "Default Web Site", 117# "PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot", 118# "State": "Stopped" 119# } 120# } 121 122# This stops an existing site. 123# $ ansible -i hosts -m community.windows.win_iis_website -a "name='Default Web Site' state=stopped" host 124 125# This creates a new site. 126# $ ansible -i hosts -m community.windows.win_iis_website -a "name=acme physical_path=C:\\sites\\acme" host 127 128# Change logfile. 129# $ ansible -i hosts -m community.windows.win_iis_website -a "name=acme physical_path=C:\\sites\\acme" host 130''' 131