Skip to content

Instantly share code, notes, and snippets.

@lindsm
Created November 9, 2016 22:27
Show Gist options
  • Save lindsm/adb65dcf0833a07c37ad829c5bd2de48 to your computer and use it in GitHub Desktop.
Save lindsm/adb65dcf0833a07c37ad829c5bd2de48 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
tasks:
- set_fact:
store: "{{ ansible_env.store }}"
source_path: "D:\\LOCALIZATION\\Export\\{{ ansible_env.store }}"
destination_file: "D:\\LOCALIZATION\\{{ ansible_env.store }}.zip"
- mssql_query:
server: sql01
database: STOREINFO_TOOL
query: 'select * from store_details where store_id = {{ store }}'
user: user
password: pass
register: query_result
# - debug: var=query_result.results
- copy:
content: "{{ query_result.results }}"
dest: "../store_info.yml"
- hosts: server
tasks:
- debug: var=localhost[server]
- name: "Remove {{ destination_file }} if it exists."
win_file: "path={{ destination_file }} state=absent"
- name: zip up {{ source_path }} to {{ destination_file }}
win_shell: Add-Type -assembly system.io.compression.filesystem; [io.compression.zipfile]::CreateFromDirectory('{{ source_path }}', '{{ destination_file }}')
args:
executable: powershell
register: zip_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment