i am getting the below error,,,

 msg: |-
    The task includes an option with an undefined variable. The error was: 
'cur_datemqm' is undefined

    The error appears to have been in 
'/opt/WebSphere/scripts/Applications/projects/timetravel/printdate.yml': 
line 23, column 9, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

               msg: "Current Date on TT servers is: {{ cur_date}}"
          - name: "Displaying the Current Date on the TT servers"
            ^ here


On Wednesday, June 12, 2019 at 1:43:27 PM UTC-5, Raj Martha wrote:
>
> Hi All,
>
> i am trying to send an one email after the playbook is done, but some how 
> i am getting the errors, i have tow tasks, and the out put of that tasks i 
> defined  as two set_facts, but some reason it is not working if i use the 
> two set-facts, if i use only one set_fact it is working fine, below is my 
> playbook, can some one please help me?
>
>
>
> ---
>   - hosts: all
>     become: true
>     tasks:
>       - name: "Printing the Date on the servers as wsadmin user"
>         become_user: wsadmin
>         shell: "date"
>         register: current_date
>         when: (inventory_hostname in groups ['wsadmindate'])
>       - name: "Printing the Date on the servers as mqm user"
>         become_user: mqm
>         shell: "date"
>         register: current_date_mqm
>         when: (inventory_hostname in groups ['mqmdate'])
>       - set_fact:
>            cur_date: "{{ current_date.stdout[0:]}}"
>         #   cur_datemqm: "{{ current_date_mqm.stdout[0:]}}"
>         run_once: True
>         with_items: (inventory_hostname in groups ['wsadmindate'])
>       - name: "Displaying the Current Date on the TT servers"
>         debug:
>            msg: "Current Date on TT servers is: {{ cur_date}}"
>       - set_fact:
>            cur_datemqm: "{{ current_date_mqm.stdout}}"
>         with_items: (inventory_hostname in groups ['mqmdate'])
>       - name: "Displaying the Current Date on the TT servers"
>         debug:
>            msg: "Current Date on TT servers is: {{ cur_datemqm}}"
>       - name: "Email The Results"
>         mail:
>           to: [email protected]
>           subject: "TT Email from Ansible With Server Date"
>           body: |
>                {% for host in groups ['wsadmindate'] %}
>                Server {{ host }} Current Date is: {{ 
> hostvars[host]['cur_date'] }}
>                {% endfor %}
>           from: deploy
>         delegate_to: localhost
>         run_once: True
>       - name: "Email The Results As MQM user"
>         mail:
>           to: [email protected]
>           subject: "TT Email from Ansible With Server Date"
>           body: |
>                {% for host in play_hosts  %}
>                Server {{ host }} Current Date is: {{ 
> hostvars[host]['cur_datemqm'] }}
>                {% endfor %}
>           from: deploy
>         delegate_to: localhost
>         run_once: True
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/245ee70f-07e9-4268-af87-48ac0d9ab0ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to