Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-15154

There should be 'delegate_to: localhost' parameter in tasks "Create the facts directory if it does not exist" and "Save facts to file"...

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • DO457 - RHAAP2.3-en-5-20241122
    • DO457
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • en-US (English)

      Please fill in the following information:


      URL: https://rol.redhat.com/rol/app/courses/do457-2.3/pages/ch04s04
      Reporter RHNID: shasingh01
      Section Title: Guided Exercise: Gathering Facts from Managed Network Devices                                                                       

      Issue description

      Description:  There should be 'delegate_to: localhost' parameter in tasks "Create the facts directory if it does not exist" and "Save facts to file"
      It somehow works without them but the code is not clear

      • name: Gather and display facts for managed nodes
         hosts: ios,junos
         gather_facts: false
         tasks:
         - name: Create the facts directory if it does not exist
         ansible.builtin.file:
         path: facts
         state: directory
         mode: 0751
         run_once: true

       - name: Gather IOS facts
       cisco.ios.ios_facts:
       gather_subset:
       - all
       when: ansible_network_os == 'cisco.ios.ios'

       - name: Gather Junos facts
       junipernetworks.junos.junos_facts:
       gather_subset:
       - all
       when: ansible_network_os == 'junipernetworks.junos.junos'

       - name: Save facts to file
       ansible.builtin.copy:
       content: "{{ ansible_facts | to_nice_yaml }}"
       dest: "facts/{{ inventory_hostname }}.txt"
       mode: 0640 

      Steps to reproduce:

       

      Workaround:

       

      Expected result:

              glsbugs-automation@redhat.com PTL - Ansible Team
              shasingh01 Shashi Singh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: