Re: [ansible-project] Multiple commands output in a single file

2021-06-03 Thread Dick Visser
Hi I asked explicitly (twice) for the value of the print_output variable. But you again did something else, which gives an error. Please try to read carefully and try again with just the print_output variable. On Thu, 3 Jun 2021 at 07:43, Djay wadhwa wrote: > > Hi D > > Ran this code and got the

Re: [ansible-project] Multiple commands output in a single file

2021-06-02 Thread Djay wadhwa
Hi D Ran this code and got the error. - name: TACACS ios_command: authorize: yes provider: "{{ cli }}" commands: - show run | in address ipv4 - show ver register: print_output - debug: var=print_outpu

Re: [ansible-project] Multiple commands output in a single file

2021-06-01 Thread Dick Visser
On Tue, 1 Jun 2021 at 13:10, Djay wadhwa wrote: > > Hi Dick I think if we use print_output.stdout[1] }} without 0 or 1 in it, it > will throw a syntax error. > > Print_output.stdout alone might be invalid. Please let's not waste more time by thinking of what might be. Instead post the value of

Re: [ansible-project] Multiple commands output in a single file

2021-06-01 Thread Djay wadhwa
Hi Dick I think if we use print_output.stdout[1] }} without 0 or 1 in it, it will throw a syntax error. Print_output.stdout alone might be invalid. Thanks On Tuesday, June 1, 2021 at 4:23:59 PM UTC+10 new_ansible wrote: > I think you can test once with > > with_items: "{{ print_output.stdo

Re: [ansible-project] Multiple commands output in a single file

2021-06-01 Thread Dick Visser
What does print_output look like? Without that we're just guessing. Bbit of a confusing variable name btw On Mon, 31 May 2021 at 07:58, Djay wadhwa wrote: > > Hi All > > > I have this ansible code where i need output of all these commands in one > file, however, all i am getting is either outpu

Re: [ansible-project] Multiple commands output in a single file

2021-05-31 Thread The Vandyy Vines
I think you can test once with with_items: "{{ print_output.stdout }} On Tue, 1 Jun 2021 at 8:12 AM, Djay wadhwa wrote: > Hi Pushp, > > Script worked but desired outcome not achieved. still getting output of > only 1st command ( show ip name-servers) in the file. > > - name: Check Ip routes >

Re: [ansible-project] Multiple commands output in a single file

2021-05-31 Thread Djay wadhwa
Hi Pushp, Script worked but desired outcome not achieved. still getting output of only 1st command ( show ip name-servers) in the file. - name: Check Ip routes hosts: routers gather_facts: false connection: local vars: cli: username: "{{ hdn_user_rw }}" password: "{{ h

Re: [ansible-project] Multiple commands output in a single file

2021-05-31 Thread Rajthecomputerguy
There is a indentation error in your playbook - name: save output to a file lineinfile: create: yes line: "{{item}}" path: /opt/ansible/dev/Dheeraj/verf/adnan/Log/{{ inventory_hostname }}.txt with_items: "{{ print_output.stdout[1] }}" On Tue, Jun 1, 2021 a

Re: [ansible-project] Multiple commands output in a single file

2021-05-31 Thread Djay wadhwa
Hi Pushpraj, I am getting the error below if i try to run this with lineinfile as per suggestion. Please see my playbook as attached. Appreciate your help --- - name: Routers data hosts: routers gather_facts: false connection: local vars: cli: username: "{{ hdn_user_rw }}"

Re: [ansible-project] Multiple commands output in a single file

2021-05-31 Thread Rajthecomputerguy
Can you try this Use this to write several strings into a file: - name: save output to a file lineinfile: create: yes line: "{{item}}" path: ./output/{{ inventory_hostname }}.txt with_items: "{{ print_output.stdout[1] }}" On Mon, May 31, 2021 at 11:28 AM Djay wadhwa wrote: > H

[ansible-project] Multiple commands output in a single file

2021-05-30 Thread Djay wadhwa
Hi All I have this ansible code where i need output of all these commands in one file, however, all i am getting is either output of first command or second command if i change the following to 0,1,2 however ansible is not appending/writing all outputs into a single file. Appreciate if the