-
-
Save makr123/a79063edb6d900b46446ae217134d611 to your computer and use it in GitHub Desktop.
Ansible Windows playbook example - creates an IIS website and deploys files for it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: windows | |
vars: | |
ansible_site_path: "c:\\inetpub\\wwwroot\\ansibletest" | |
staging_path: "c:\\deploy" | |
ansible_test_staging_path: "{{ staging_path }}\\ansible-test-site-{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}" | |
tasks: | |
- name: install-iis | |
win_feature: | |
name: "Web-Server" | |
state: present | |
restart: no | |
include_sub_features: yes | |
include_management_tools: no | |
- name: create staging path | |
win_file: path={{ staging_path }} state=directory | |
- name: default-website-index | |
win_copy: | |
src: files/index.html | |
dest: "C:\\inetpub\\wwwroot\\index.html" | |
- name: create new website's directory | |
win_file: path={{ ansible_site_path }} state=directory | |
- name: create new website | |
win_iis_website: | |
name: "Ansible Test Site" | |
state: started | |
port: 8080 | |
physical_path: "{{ ansible_site_path }}" | |
- name: Open site's port on firewall | |
win_firewall_rule: | |
name: mysite8080 | |
enable: yes | |
state: present | |
localport: 8080 | |
action: Allow | |
direction: In | |
protocol: Tcp | |
force: true | |
tags: firewall | |
- name: create deploy staging path | |
win_file: path={{ ansible_test_staging_path }} state=directory | |
- name: get code to deploy staging path | |
win_copy: | |
src: files/site.zip | |
dest: "{{ ansible_test_staging_path }}" | |
- name: unzip code to site path | |
win_unzip: | |
src: "{{ ansible_test_staging_path }}\\site.zip" | |
dest: "{{ ansible_site_path }}" | |
creates: "{{ ansible_site_path }}\\index.html" | |
tags: unzip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment