---
- hosts: SW-Switches
gather_facts: no
connection: local
vars_prompt:
- name: "mgmt_username"
prompt: "Username"
private: no
- name: "mgmt_password"
prompt: "Password"
tasks:
- name: Provider
set_fact:
provider:
host: "{{ inventory_hostname }}"
username: "{{ mgmt_username }}"
password: "{{ mgmt_password }}"
- name: Show run
ios_command:
provider: "{{ provider }}"
commands:
- command: show running-configuration
register: showrun
- name: save output
copy:
content: "{{ showrun.stdout }}"
dest: "/etc/ansible/show_run_test11.22.conf"
~[root@BX-ANSIBLE ansible]# ansible-playbook test11.22.yml
Username: ########
Password: ########
PLAY [SW-Switches] *********************************************************************************
TASK [SYS | Define provider] ***********************************************************************
ok: [BX-COM-SW6]
TASK [IOS | Show run] ******************************************************************************
fatal: [BX-COM-SW6]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ios_command) module: register Supported parameters include: auth_pass, authorize, commands, host, interval, match, password, port, provider, retries, ssh_keyfile, timeout, username, wait_for"}
to retry, use: --limit @/etc/ansible/test11.22.retry
PLAY RECAP *****************************************************************************************
BX-COM-SW6 : ok=1 changed=0 unreachable=0 failed=1--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d3b29d2a-2aa7-4c90-a4ae-544b6076a4bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- name: IOS | Datadump + Show run
ios_config:
authorize: yes
provider: "{{ provider }}"
commands:
- terminal datadump
register: showrun
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py", line 113, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py", line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py", line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/tmp/ansible_ios_config_payload_5TvH1X/__main__.py", line 541, in <module>
File "/tmp/ansible_ios_config_payload_5TvH1X/__main__.py", line 472, in main
File "/tmp/ansible_ios_config_payload_5TvH1X/__main__.py", line 333, in edit_config_or_macro
File "/tmp/ansible_ios_config_payload_5TvH1X/ansible_ios_config_payload.zip/ansible/module_utils/connection.py", line 173, in __rpc__
ansible.module_utils.connection.ConnectionError: operation requires privilege escalation
fatal: [BX-COM-SW6]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py\", line 113, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1548834885.34-267057542623206/AnsiballZ_ios_config.py\", line 48, in invoke_module\n imp.load_module('__main__', mod, module, MOD_DESC)\n File \"/tmp/ansible_ios_config_payload_5TvH1X/__main__.py\", line 541, in <module>\n File \"/tmp/ansible_ios_config_payload_5TvH1X/__main__.py\", line 472, in main\n File \"/tmp/ansible_ios_config_payload_5TvH1X/__main__.py\", line 333, in edit_config_or_macro\n File \"/tmp/ansible_ios_config_payload_5TvH1X/ansible_ios_config_payload.zip/ansible/module_utils/connection.py\", line 173, in __rpc__\nansible.module_utils.connection.ConnectionError: operation requires privilege escalation\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}"connection: network_cli" and "become: yes" with "become_pass""ansible.module_utils.connection.ConnectionError: operation requires privilege escalation "--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ba3903bb-1080-4273-b177-b90fa6de8fc9%40googlegroups.com.
---- hosts: ####### gather_facts: yes connection: local become: pass
vars: date: "{{ lookup('pipe', 'date +%Y.%m.%d-%H:%M') }}"
vars_prompt: - name: "mgmt_username" prompt: "Username" private: no - name: "mgmt_password" prompt: "Password"
tasks:
- name: SYS | Define provider set_fact: provider: host: "{{ inventory_hostname }}" username: "{{ mgmt_username }}" password: "{{ mgmt_password }}"
- name: show run ios_command: provider: "{{ provider }}" commands: - command: 'copy running-config tftp://##.###.###.##/{{ inventory_hostname }}.{{ date }}.txt'