Confusion about storing and accessing variables

10 views
Skip to first unread message

Matt Hickok

unread,
Dec 4, 2018, 12:44:19 PM12/4/18
to Ansible Project
Hello, I'm trying to store a cisco device config in the fact cache, I'm doing it like this: 

    - name: "Get Config"
      register: config
      ios_command:
        commands: show running-config

    - name: "Store config as fact"
      set_fact:
        config: "{{ config.stdout }}"
        cacheable: true

While it's working, the resulting fact being created is the entire output from ios_command, meaning it includes changed, failed, stdout, and stdout_lines. 

I thought I was created a variable with "register: config" and then was storing just the stdout part of the variable by doing: config: "{{ config.stdout }}"

Is that not the proper way of accessing a variable?

Reply all
Reply to author
Forward
0 new messages