ansible-playbook -vvvv -i hosts playbook.yml --extra-vars='ansible_user=ansible ansible_password=A****0+ ansible_connection=winrm ansible_winrm_server_cert_validation=ignore var1=value1'
Created
January 24, 2020 10:45
-
-
Save kagarlickij/92683649b580333a111ddbd738f1e9d1 to your computer and use it in GitHub Desktop.
Sample Ansible playbook that uses Windows hostname for creating file and running command
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
var1: {{ var1 }} | |
var2: {{ ansible_hostname }} |
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
[all] | |
40.71.194.145 |
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: all | |
vars: | |
var1: | |
var2: "$env:COMPUTERNAME" | |
tasks: | |
- name: ping | |
win_ping: | |
- name: Create file using hostname | |
win_template: | |
src: build_config_template.j2 | |
dest: C:\build_config.txt | |
- name: Run command using hostname | |
win_shell: | | |
Write-Output "hello from {{ var2 }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment