test.yml
--- - name: CloudEngine hosts: route connection: network_cli gather_facts: no vars: cli: hosts: "{{inventory_hostname}}" port: "{{ansible_ssh_port}}" username: "{{ansible_ssh_user}}" password: "{{ansible_ssh_pass}}" transport: cli tasks: - name: "save config" ansible.netcommon.cli_command: command: '{{item}}' prompt: - Y/N answer: Y loop: - system-view - snmp-agent trap enable - return - save register: output - debug: msg={{output}}
ansible.cfg
[defaults] inventory = ~/.ansible/hosts host_key_checking = False timeout = 5
hosts
[route] 192.168.0.1 ansible_ssh_user=xxx ansible_ssh_pass="xxx" [route:vars] ansible_connection = network_cli ansible_network_os = ce ansible_port = 22 ansible_ssh_user = xxx ansible_ssh_pass = xxx