Skip to content

Instantly share code, notes, and snippets.

@devilrancy
Created February 19, 2017 18:16
Show Gist options
  • Save devilrancy/b2630ffd7c438d0d71608d2f4cb9e8b3 to your computer and use it in GitHub Desktop.
Save devilrancy/b2630ffd7c438d0d71608d2f4cb9e8b3 to your computer and use it in GitHub Desktop.
This is an Example Gist for windows ansible
devilrancy@DESKTOP-VNKH637:~/dev-work/ansible-windows-playbook$ ansible-playbook -i hosts win-playbook.yml
PLAY [win] *********************************************************************
TASK [setup] *******************************************************************
ok: [192.168.1.1]
TASK [run ipconfig] ************************************************************
changed: [192.168.1.1]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"msg": [
"",
"Windows IP Configuration",
"",
"",
"Ethernet adapter Ethernet:",
"",
" Connection-specific DNS Suffix . : ec2.internal",
" Link-local IPv6 Address . . . . . : 895b::98cd:2fbe:76d4:d397%13",
" IPv4 Address. . . . . . . . . . . : 192.168.1.1",
" Subnet Mask . . . . . . . . . . . : 255.255.240.0",
" Default Gateway . . . . . . . . . : 192.168.1.0",
"",
"Tunnel adapter isatap.ec2.internal:",
"",
" Media State . . . . . . . . . . . : Media disconnected",
" Connection-specific DNS Suffix . : ec2.internal",
"",
"Tunnel adapter Local Area Connection* 12:",
"",
" Connection-specific DNS Suffix . : ",
" IPv6 Address. . . . . . . . . . . : 768:0:b9vn:7540:3cbe:2fbe:53e0:d532",
" Link-local IPv6 Address . . . . . : 895b::98cd:2fbe:76d4:d397%13",
" Default Gateway . . . . . . . . . : ::"
]
}
TASK [create directory for code base] ******************************************
changed: [192.168.1.12]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"create_dir": {
"changed": true
}
}
TASK [download code base] ******************************************************
changed: [192.168.1.1]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"msg": "Cloning into 'robotdemo'...\n"
}
TASK [check python version] ****************************************************
changed: [192.168.1.1]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"msg": "Python 2.7.13\r\n"
}
TASK [copy the executor file] **************************************************
changed: [192.168.1.1]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"run_std": {
"changed": true,
"checksum": "ed53b1426b148257acd218750e5f73f1d39c4566",
"operation": "file_copy",
"original_basename": "run_command.py",
"size": 47
}
}
TASK [run python command] ******************************************************
changed: [192.168.1.1]
TASK [debug] *******************************************************************
ok: [192.168.1.1] => {
"msg": [
"==============================================================================",
"Data Driven :: Example test cases using the data-driven testing approach. ",
"==============================================================================",
"Addition | PASS |",
"------------------------------------------------------------------------------",
"Subtraction | PASS |",
"------------------------------------------------------------------------------",
"Multiplication | PASS |",
"------------------------------------------------------------------------------",
"Division | PASS |",
"------------------------------------------------------------------------------",
"Failing | FAIL |",
"2 != 3",
"------------------------------------------------------------------------------",
"Calculation error | PASS |",
"------------------------------------------------------------------------------",
"Data Driven :: Example test cases using the data-driven testing ap... | FAIL |",
"6 critical tests, 5 passed, 1 failed",
"6 tests total, 5 passed, 1 failed",
"==============================================================================",
"Output: C:\\code\\robotdemo\\output.xml",
"Log: C:\\code\\robotdemo\\log.html",
"Report: C:\\code\\robotdemo\\report.html"
]
}
PLAY RECAP *********************************************************************
192.168.1.1 : ok=13 changed=6 unreachable=0 failed=0
- hosts: win
tasks:
- name: run ipconfig
raw: ipconfig
register: ipconfig
- debug: msg={{ ipconfig.stdout_lines }}
- name: create directory for code base
win_file:
path: C:\code
state: directory
register: create_dir
- debug: var=create_dir
- name: download code base
win_command: git clone https://bitbucket.org/robotframework/robotdemo.git
args:
chdir: "C:\\code"
register: git_code
- debug: msg={{ git_code.stderr }}
- name: check python version
win_command: python --version
register: python_vr
- debug: msg={{ python_vr.stderr }}
- name: copy the executor file
win_copy:
src: "run_command.py"
dest: "C:\\code\\robotdemo\\"
register: run_std
- debug: var=run_std
- name: run python command
win_command: python run_command.py
args:
chdir: "C:\\code\\robotdemo\\"
register: pybot_std
- debug: msg={{ pybot_std.stdout_lines }}
[win]
192.168.1.1
[win:vars]
ansible_ssh_user=<admin_use>
ansible_ssh_pass=<admin_password>
ansible_ssh_port=5985
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment