The first line has to be in this format " [email protected]> show
chassis hardware detail | display xml | no-more ". By the way, there is no
DNS working and I am just using IP addresses. I probably use RPC XML and
see if I can change the file name to that format then use tail. Or just
PyEZ.

Thanks


On Wed, May 19, 2021 at 8:15 AM Dick Visser <[email protected]> wrote:

> Can't you combine the results with another query that returns that
> hostname?
>
> On Wed, 19 May 2021 at 13:46, Alaeddin Gabsi <[email protected]> wrote:
>
>> Thank you, Dick;
>>
>> I thought that maybe it should be some kind of option to print the STDIN.
>> In my case, an inventory report without hostnames can not be used.
>>
>> I then probably should use a python script for this.
>>
>> Thanks
>>
>> On Wed, May 19, 2021 at 3:20 AM Dick Visser <[email protected]>
>> wrote:
>>
>>> This is a best effort mailing list run mostly by volunteers. I
>>> wouldn't expect a response in a few hours.
>>>
>>> I may be wrong, but given that the purpose of the network modules
>>> (such as the junos ones) is to abstract away the CLI interaction, what
>>> you're asking sounds like the opposite?
>>>
>>> On Wed, 19 May 2021 at 07:47, Al Gabsi <[email protected]> wrote:
>>> >
>>> > Wondering if anyone has an answer to this :-)
>>> >
>>> > On Tuesday, May 18, 2021 at 4:13:34 PM UTC-4 Al Gabsi wrote:
>>> >>
>>> >>
>>> >>
>>> >> Hello Everyone;
>>> >>
>>> >> Could you please guide me on how to be able to print the CLI command
>>> to the log file?
>>> >> For example, if I am  backing up inventory, and I am using "show
>>> chassis hardware", I would like to see something like this:
>>> >>
>>> >> [email protected]> show chassis hardware detail | display
>>> xml | no-more
>>> >> <rpc-reply xmlns:junos="http://xml.juniper.net/junos/17.3R3/junos";>
>>> >>     <chassis-inventory xmlns="
>>> http://xml.juniper.net/junos/17.3R3/junos-chassis";>
>>> >>         <chassis junos:style="inventory">
>>> >>             <name>Chassis</name>
>>> >>
>>> >> Currently, I am only seeing the output and not seeing the hostname
>>> with the CLI command.
>>> >>
>>> >> Here is my script
>>> >> This my current output. It is not show ing the CLI
>>> >> <chassis-inventory>. ==> this is my first line
>>> >>   <chassis style="inventory">
>>> >>     <name>Chassis</name>
>>> >>     <serial-number>JN111F17FAFA</serial-number>
>>> >>
>>> >> ------------------------------
>>> >>
>>> >> ---
>>> >> - name: Get Device Facts
>>> >>   hosts: lab-nep6
>>> >>   connection: local
>>> >>   gather_facts: no
>>> >>   roles:
>>> >>     - juniper.junos
>>> >>   vars_prompt:
>>> >>     - name: USERNAME
>>> >>       prompt: Username
>>> >>       private: no
>>> >>     - name: PASSWORD
>>> >>       prompt: password
>>> >>       private: yes
>>> >>   tasks:
>>> >>     - name: Get inventory_hostname
>>> >>       juniper_junos_command:
>>> >>         host: "{{ inventory_hostname }}"
>>> >>         port: 22
>>> >>         user: "{{ USERNAME }}"
>>> >>         password: "{{ PASSWORD }}"
>>> >>         commands: "show chassis hardware detail"
>>> >>         formats:
>>> >>           - "xml"
>>> >>         dest: "tmp/inventory-nep6/{{ inventory_hostname }}__{{
>>> '%m-%d-%Y' | strftime }}.output"
>>> >>
>>> >>
>>> >> Thank you in advance :-)
>>> >>
>>> >>
>>> >>
>>> > --
>>> > 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/0c15c623-cc24-4714-af2f-0994f1de77c6n%40googlegroups.com
>>> .
>>>
>>>
>>>
>>> --
>>> Dick Visser
>>> Trust & Identity Service Operations Manager
>>> GÉANT
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNp6uWr7pC_s8_yrCmszYK0NX5YHQNKgb7xgPAvUOdTDw%40mail.gmail.com
>>> .
>>>
>>
>>
>> --
>> Thank You
>> Alaeddin Gabsi
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CACgK2V%2BMbNu7-r17MTWRNGVZYbs9Ed%2BQmz6Znq%2BKLmJoaaM3Kw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CACgK2V%2BMbNu7-r17MTWRNGVZYbs9Ed%2BQmz6Znq%2BKLmJoaaM3Kw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMz2WnzsMqR5BKGuxHw9eRtAGK8hee8By7S5k%3DgqCB1DA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwMz2WnzsMqR5BKGuxHw9eRtAGK8hee8By7S5k%3DgqCB1DA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thank You
Alaeddin Gabsi

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACgK2VJh5YzXvQnPOD-PHZC_BYregqSmBgmrHp%3DZvZu6JyyAOw%40mail.gmail.com.

Reply via email to