On Wed, Dec 8, 2021 at 10:36 AM Todd Lewis <
uto...@gmail.com> wrote:
>
> What's showing in {{log_dir}}/log.out? Or rather, what's new in that file? Since you're appending to it (tee -a), if it had prior content it would still have that content.
> Maybe throw a date >> {{ log_dir }}/log.out in there before the tomcat upgrade, just to be sure:
>
> - name: Test
> ansible.builtin.shell: |
> date >> {{ log_dir }}/log.out
> {{sources_dir}}/scripts/tomcat/upgrade.sh {{tmp_dir}}/{{
item.name}}.props 2>&1 | \
> tee -a {{log_dir}}/log.out
> exit ${PIPESTATUS[0]}
Shell scripts with "|" in them don't report an exit status of the
first element automatically, unless "pipefail" is enabled. For
debugging, I'd suggest using:
set -o pipefail
date 2>&1 | tee -a {{ log_dir }}/log.out
{{sources_dir}}/scripts/tomcat/upgrade.sh
{{tmp_dir}}/{{
item.name}}.props 2>&1 tee -a {{log_dir}}/log.out
And if more verbosity is necessary, use "set -x" in your upgrade.sh script.
> On 12/8/21 10:18 AM, dimple rohara wrote:
>
> the out is showing is "" in debug.
>
> On Wednesday, 8 December 2021 at 10:14:31 UTC-5 dimple rohara wrote:
>>
>> This is the whole snippet. I have sanitized it a bit so let me know if it doesn't makes sense.
>>
>> - name: Test
>>
>> ansible.builtin.shell: "{{sources_dir}}/scripts/tomcat/upgrade.sh {{tmp_dir}}/{{
item.name}}.props 2>&1 | tee -a {{log_dir}}/log.out; exit ${PIPESTATUS[0]} "
>>
>> register: out
>>
>> with_items: [ "{{instances[deployment]}}" ]
>>
>> - debug: msg= "{{ out }}"
>>
>>
>> On Wednesday, 8 December 2021 at 01:43:16 UTC-5
dick....@geant.org wrote:
>>>
>>> On Wed, 8 Dec 2021 at 00:11, dimple rohara <
dimple....@gmail.com> wrote:
>>>>
>>>> Hi, I am using ansible.builtin.shell, but it's returning no output of the execution on console.
>>>> I am using it like this:
>>>> ansible.builtin.shell: "{{sources_dir}}/scripts/tomcat/upgrade.sh {{tmp_dir}}/{{
item.name}}.props 2>&1 | tee -a {{log_dir}}/log.out; exit ${PIPESTATUS[0]} "
>>>>
>>>> I am getting the output in the file but nothing on console or the registered variable.
>>>
>>>
>>> Which registered variable? The code you've posted doesn't contain any.
>>> Without that there would indeed be "nothing on console". So, everything works as it should.
>>>
>
> --
> 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
ansible-proje...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1b9e6589-a6cd-d9c4-32d4-87f5a633ed36%40gmail.com.