I launch a script which give me some informations on my devices but I have the result only in my Ansible Console. I would like to have this informations on a file on my control manager. In the script they are store in the variable $Ansible.Result.
How can I put it in a file ?
Code of my playbook.yaml
- name: firsttest
hosts: win
tasks:
- name: Ping my Windows vm
win_ping:
- name: Run basic PowerShell script
ansible.windows.win_powershell:
script: |
$hostname = hostname
$domain = Get-NetFirewallProfile -Name Domain | Select-Object -ExpandProperty Enabled | Out-String
$private = Get-NetFirewallProfile -Name Private | Select-Object -ExpandProperty Enabled | Out-String
$public = Get-NetFirewallProfile -Name Public | Select-Object -ExpandProperty Enabled | Out-String
$ipaddress = Get-NetIPAddress -AddressFamily IPv4 | Select-Object -ExpandProperty IPAddress | Out-String
$myObject = [PSCustomObject]@{
"Hostname" = $hostname
"IPAdress" = $ipaddress
"Domain" = $domain
"Private" = $private
"Public" = $public
}
$Ansible.Result = $myObject
register: result
- name: Show PS_output
debug:
var: result