C
C
CanisLupusMSK2021-10-18 17:27:42
network hardware
CanisLupusMSK, 2021-10-18 17:27:42

How to remove spaces in configuration file when copying to file?

There is a task to remove backups from switches with ansymbol.

playbook

- name: sh running allied
  hosts: switch
  gather_facts: false
  connection: network_cli
  collections:
    - alliedtelesis.awplus

  tasks:
    - name: run show version on remote devices
      awplus_command:
        commands:
          - command: 'sh run'
      register: config
    - name: write
      copy:
        content: "{{config.stdout}}"
        dest: "/etc/allied_ansible/{{ inventory_hostname }}"


The config is written to the file without spaces, how can I fix this? I.e:

nplatform hwfilter-size ipv4-full-ipv6\n!\nno service telnet\n!\nservice http\n!\nclock timezone MSK plus 3:00\n!\nno snmp-server ipv6\nsnmp-server community public \n!\n!\naaa authentication enable default local\naaa authentication login default local\n!\n!\n!\nstack virtual-chassis-id 1711\n!\n!\n!\nntp peer 10.13.2.1\n!\n!\nip name-server


I would like to pick up a normal config

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Barbolin, 2021-10-18
@CanisLupusMSK

https://blog.noblinkyblinky.com/2020/10/26/capturi...

content: "{{ config.stdout | replace('\\n', '\n') }}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question