Created
May 24, 2023 15:26
-
-
Save zeitounator/db82cbec4e65029df79cf2c23d5b0d49 to your computer and use it in GitHub Desktop.
https://stackoverflow.com/questions/76316666/ansible-check-remote-hosts-and-include-results-in-email
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
# Note: this is an exact copy/paste from the question | |
$ cat test.yml | |
- hosts: all | |
name: check patching | |
gather_facts: 'no' | |
tasks: | |
- name: Get list | |
win_shell: >- | |
(New-Object -ComObject | |
Microsoft.Update.Session).CreateupdateSearcher().Search(“IsHidden=0 and | |
IsInstalled=0”).Updates | Select-Object Title | |
register: List | |
- hosts: localhost | |
tasks: | |
- name: mail out | |
host: 1.1.1.1 | |
port: 25 | |
from: [email protected] | |
to: [email protected] | |
subject: patches | |
body: '(( hostvars[''????''][''List''].stdout_lines }}' | |
$ ansible-playbook test.yml | |
[WARNING]: No inventory was parsed, only implicit localhost is available | |
ERROR! conflicting action statements: host, from | |
The error appears to be in '/tmp/test/test.yml': line 13, column 7, but may | |
be elsewhere in the file depending on the exact syntax problem. | |
The offending line appears to be: | |
tasks: | |
- name: mail out | |
^ here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment