Last active
March 4, 2020 18:19
-
-
Save jonathanmedd/f5a5dd36e7332e10b808b7d6c4b48d77 to your computer and use it in GitHub Desktop.
_test_pwsh7
This file contains 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 | |
tasks: | |
- name: Run a script | |
shell: "{{ playbook_dir }}/files/test_output4.ps1" | |
args: | |
executable: /usr/bin/pwsh | |
register: result1 | |
- name: Process output | |
set_fact: | |
errorDetail: "{{ result1.stdout | from_json }}" | |
- debug: | |
msg: "Error Category: {{ errorDetail.Category }}, Error Activity: {{ errorDetail.Activity }}, Error Reason: {{ errorDetail.Reason }} for Target {{ errorDetail.TargetName }}" | |
- name: Invoke-RestMethod via shell module | |
shell: Invoke-RestMethod -Uri 'https://httpbin.org/get' | ConvertTo-Json | |
args: | |
executable: /usr/bin/pwsh | |
register: apiRequest | |
- name: Process output | |
set_fact: | |
apiOutput: "{{ apiRequest.stdout | from_json }}" | |
- debug: | |
msg: "The User-Agent used to make the API request was {{ apiOutput.headers['User-Agent'] }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment