Skip to content

Instantly share code, notes, and snippets.

@kaz-tk
Created September 23, 2014 12:19
Show Gist options
  • Save kaz-tk/41a59f79be4b5cc200be to your computer and use it in GitHub Desktop.
Save kaz-tk/41a59f79be4b5cc200be to your computer and use it in GitHub Desktop.
ansible for windows
echo NotImplementedYet > {{DATETIME}}.log
echo NotImplementedYet > {{DATETIME}}.log
[local]
127.0.0.1
[win]
172.16.1.2 ansible_ssh_user=Administrator ansible_connection=winrm ansible_ssh_port=5986 ansible_ssh_pass=cobbler00Admin
[cobbler_win]
172.16.1.1 ansible_ssh_user=Administrator ansible_connection=winrm ansible_ssh_port=5986 ansible_ssh_pass=cobbler00Admin
New-Item {{work_dir}} -type Directory
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
- name: windows bootstrapping
hosts: win
vars:
- base_url: "http://172.16.0.3/files"
# - tmp_dir: 'C:\Users\Administrator\AppData\Local\Temp'
- tmp_dir: 'C:\Users\Administrator\Desktop'
- work_dir: '{{tmp_dir}}\\{{DATETIME}}'
tasks:
###########################################
# 事前準備
###########################################
- name: mkdir {{workdir}}
raw: iex (New-Item {{work_dir}} -type Directory)
# only file no directory
- name: list forward files.
local_action: shell find files/ -type f
register: forward_files
- name: copy files for preparing to download from windows.
local_action: shell cp -r {{item}} /var/www/html/{{item}}
with_items: forward_files.stdout_lines
- name: download files
win_get_url:
url: '{{base_url}}/{{item|basename}}'
dest: '{{work_dir}}\{{item|basename}}'
with_items: forward_files.stdout_lines
###########################################
# 変更作業
###########################################
- name: install Tortoise SVN
win_msi: path='{{work_dir}}\TortoiseSVN-1.8.8.25755-x64-svn-1.8.10.msi'
creates='C:\Program Files\TortoiseSVN'
state=present
- name: install 7zip
win_msi: path='{{work_dir}}\7z920-x64.msi'
state=present
###########################################
# 事後作業
###########################################
# sorry for timeup
- name: create archive(logs)
raw:
- name: fetching logs and archive
slurp:
#!/bin/bash
# License: Apache License
# usage
_usage="
=== usage ===
本スクリプトは、私のWindows環境をセットアップするスクリプトです。。
"
# ----- user variable definition -----
playbook="./site.yml"
# ----- variable definition -----
_loop=0
dir_base=`pwd`
DATETIME=`date "+%Y%m%d_%H%M%S"`
inventories=()
inventories_index=1
# ----- function _definition -----
ansible-playbook -i inventory --extra-vars "DATETIME=${DATETIME}" ${playbook}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment