title: Passing list of parameter to Powershell using Ansible
body: <p>i have a list of parameter in a YAML file call vars_sb_task.yml:</p>
  
  <pre><code>---
  type: taskWindows
  actions:
    abortActions: []
    emailNotifications: []
    setVariableActions: []
    snmpNotifications: []
    systemOperations: []
  agent: test
  name: "Test"
  summary: "Test"
  ...
  </code></pre>
  
  <p>I have a Powershell script for stonebranch task creation called sb.ps1:</p>
  
  <pre><code>function Stonebrach.Connect {
  param(
      [Parameter(Mandatory=$true)]
      $Sb_uri,
      [Parameter(Mandatory=$true)]
      $Auth_filename,
      [Parameter(Mandatory=$true)]
      $Method,
      [Parameter(Mandatory=$false)]
      $Body
  )
  
  $basicAuth=Get-Content "C:\$auth_filename"
  $headers = @{
          "Authorization" = $basicAuth
          "Content-Type"="application/json"
  }
  $RSP=$null
  
  try{
      if ( $body -eq $null ) {
          $response = invoke-restmethod -Uri $Sb_uri -Method $Method -Headers $headers
      }
      else {
          $response = invoke-restmethod -Uri $sb_uri -Method $method -Headers $headers -Body **$body**
      }
      return $response
  }
  catch{
     $RSP = $_.Exception.Message
     return $RSP
  }
  }
  
  function Stonebranch.Create.Task.Windows {
  param(
      [Parameter(Mandatory=$true)]
      $Sb_base_uri,
      [Parameter(Mandatory=$true)]
      $Auth_filename,
      [Parameter(Mandatory=$true)]
      $Method,
      [Parameter(Mandatory=$true)]
      $Body
  )
      Stonebrach.Connect -SB_uri $Sb_base_uri/task -Auth_filename 
  $Auth_filename -Method $Method -Body $Body
  }
  </code></pre>
  
  <p>i want to call the function like this:</p>
  
  <pre><code>$response = Stonebranch.Create.Task.Windows -Sb_base_uri $Sb_base_uri -Auth_filename $Auth_filename -Method POST -Body $body
  </code></pre>
  
  <p><strong>Here's the question: i want to pass all of the parameter in vars_sb_task.yml into $body, do anyone knows how to do that using Ansible?</strong> Since i intend to push that sb.ps1 into another Windows server using Ansible.</p>
  
  <p>Or you can show me how to pass that yml file using Powershell if there's no way using Ansible. Im pretty new in both field, thanks for your help.</p>
  
  <p>** Edit:
  i tried to write a playbook with the vars_sb_task.yml:</p>
  
  <pre><code>---
  - name: test vars file
    hosts: windows
    vars_files:
     - /home/tung/ansible_test/vars_sb_win_task.yml
    tasks:
    - name: test vars
      debug:
        msg: "{{ agent }}"
  </code></pre>
  
  <p>After i run this playbook, it returns 'test', since my agent have value test. If it is single variable, i can pass it into the Powershell script, but the problem is that i have to pass all variables of the yaml file into $body. I don't know what to do from here. I try to read the Ansible documentation, but it is not really clear. It would be nice if anyone could write an example how to handle and pass these variables in yaml file <strong>into a single variable</strong> in Powershell ($body in this case)</p>