Hi,
There were already few topics related using playbooks on routers and switches (systems without python).
But I didn’t find answer on next:
Does it possible with raw module send few command in one ssh session?
Unfortunately below code, create 3 connections
`
- name: copy file
raw: “{{item}};”
with_items:
- conf t
- int gi0/0
- shutdown
`
To better understanding, I would like to get same behaviour such bash construction
`
cat file.txt | ssh user@host_name
`
with_ loops normally create a separate task/action per item. You'll
need to construct the the command list using | or > (YAML multiline
operators). Something liek the following:
- name: copy file
raw: |
conf t
int gi0/0
shutdown
Hi, Brian.
As I understood this (literal style | ) is a same replacement for
raw: "conf t\n int gi0/0\n shutdow"
according yaml.org/spec it’s same
and it works like
ssh username@host "conf t\n int gi0/0\n shutdow"
ssh send ``"conf t\n int gi0/0\n shutdow" as one command, without \n sequences.
paramiko has same behaviour.