From 7296ce5304b7e91adf256589a0992d8762b7a6d1 Mon Sep 17 00:00:00 2001 From: Dave Johnson Date: Thu, 21 Aug 2014 10:01:50 -0400 Subject: [PATCH] Added test playbooks for Windows --- windows/deploy-site.yml | 11 +++++++++++ windows/enable-iis.yml | 14 ++++++++++++++ windows/files/helloworld.ps1 | 5 +++++ windows/ping.yml | 9 +++++++++ windows/run-powershell.yml | 9 +++++++++ windows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 windows/deploy-site.yml create mode 100644 windows/enable-iis.yml create mode 100644 windows/files/helloworld.ps1 create mode 100644 windows/ping.yml create mode 100644 windows/run-powershell.yml create mode 100644 windows/test.yml diff --git a/windows/deploy-site.yml b/windows/deploy-site.yml new file mode 100644 index 0000000..70114f6 --- /dev/null +++ b/windows/deploy-site.yml @@ -0,0 +1,11 @@ +--- +# This playbook uses the win_get_url module to download a simple HTML file for IIS + +- name: Download simple web site + hosts: windows + gather_facts: false + tasks: + - name: Download simple web site to 'C:\inetpub\wwwroot\ansible.html' + win_get_url: + url: 'https://raw.githubusercontent.com/thisdavejohnson/mywebapp/master/index.html' + dest: 'C:\inetpub\wwwroot\ansible.html' diff --git a/windows/enable-iis.yml b/windows/enable-iis.yml new file mode 100644 index 0000000..bc48aa3 --- /dev/null +++ b/windows/enable-iis.yml @@ -0,0 +1,14 @@ +--- +# This playbook installs and enables IIS on Windows hosts + +- name: Install IIS + hosts: all + gather_facts: false + tasks: + - name: Install IIS + win_feature: + name: "Web-Server" + state: present + restart: yes + include_sub_features: yes + include_management_tools: yes diff --git a/windows/files/helloworld.ps1 b/windows/files/helloworld.ps1 new file mode 100644 index 0000000..b7f785d --- /dev/null +++ b/windows/files/helloworld.ps1 @@ -0,0 +1,5 @@ +# Filename: helloworld.ps1 +Write-Host +Write-Host 'Hello World!' +Write-Host "Good-bye World! `n" +# end of script diff --git a/windows/ping.yml b/windows/ping.yml new file mode 100644 index 0000000..15cba8d --- /dev/null +++ b/windows/ping.yml @@ -0,0 +1,9 @@ +--- +# This playbook uses the win_ping module to test connectivity to Windows hosts +- name: Ping + hosts: windows + + tasks: + - name: ping + win_ping: + diff --git a/windows/run-powershell.yml b/windows/run-powershell.yml new file mode 100644 index 0000000..4e1efc9 --- /dev/null +++ b/windows/run-powershell.yml @@ -0,0 +1,9 @@ +--- +# This playbook tests the script module on Windows hosts + +- name: Run powershell script + hosts: windows + gather_facts: false + tasks: + - name: Run powershell script + script: files/helloworld.ps1 diff --git a/windows/test.yml b/windows/test.yml new file mode 100644 index 0000000..b347a6f --- /dev/null +++ b/windows/test.yml @@ -0,0 +1,36 @@ +--- +# This playbook uses various Windows modules to test their functionality + +- name: test raw module + hosts: windows + tasks: + - name: run ipconfig + raw: ipconfig + register: ipconfig + - debug: var=ipconfig + +- name: test stat module + hosts: windows + tasks: + - name: test stat module on file + win_stat: path="C:/Windows/win.ini" + register: stat_file + + - debug: var=stat_file + + - name: check stat_file result + assert: + that: + - "stat_file.stat.exists" + - "not stat_file.stat.isdir" + - "stat_file.stat.size > 0" + - "stat_file.stat.md5" + +- name: Add a user + hosts: all + gather_facts: false + tasks: + - name: Add User + win_user: + name: ansible + password: "@ns1bl3"