Configuring an HP GbE2c switch with SCP.

Hi there,

I’m brand new to Ansible and I would like to know how you would approach the following situation: I’m trying to push some configuration files to HP GbE2c L2/L3 switches that I maintain. I can access the switches using SSH but need to enter a password manually (no way to declare an authorized RSA key). From there I have access to a CISCO-like CLI to manage the configuration. I can also push a configuration file remotely using SCP, with a syntax like the following, for instance from a Linux host:

scp config.cfg admin@switch_ip:putcfg_apply_save
Password:

which will upload file “config.cfg” to the switch, apply the new configuration and flash it to persistent memory.

I would like to do this automatically with Ansible as I have a fairly large number of switches to manage (about 20). There are two things I need for that:
1 - A way to enter the SSH admin password automatically, like with Tcl/Tk “expect”.
2 - A way to carry an scp command locally as obviously I can’t execute any command on the remote system.

Up to now I have come with the following solution:

“ansible-playbook -k -vvv test.yml” will ask you for the ssh password and send it to each host but prompt you only once

as for the commands, try the following:

  • hosts: switches
    gather_facts: no
    user: admin
    tasks:

  • name: Push configuration to the switches
    local_action: command scp ${inventory_hostname}.cfg

  • name: save config
    raw: putcfg_apply_save