cat ~/.config/ansible/hosts
ansible --list-hosts "*" -vvv
- set_fact:
var_{{ item.index }}: "{{ item.value }}"
loop:
- index: x1
value: 'aaa'
- index: x2
value: 'bbb'
- debug: var=var_x1
- debug: var=var_x2
- name: Information about license for Windows
win_shell: |
# variant 1
Start-Process -Wait -RedirectStandardOutput C:\111 -FilePath cscript -ArgumentList 'slmgr.vbs','-dlv'
Get-Content C:\111 -Encoding OEM
# variant 2
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("cp866")
cscript slmgr.vbs -dlv > c:\222
Get-Content C:\222 -Encoding Unicode
register: infowin_out
args:
chdir: '{{ ansible_env.windir }}\System32\'
no_profile: yes
- debug: var=infowin_out
set_fact:
scriptdirs: {{ dirs. | selectattr(type, 'equalto', 'es_script') | list }}
template:
src: template.j2
dest: " {{ item.path }}"
mode: "{{ item.mode }}"
loop: "{{ scriptdirs }}"