Hello,
I finally got the answer after weeks of trying:
---
- 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'
This playbook save configuration file with the name of your switch and
date/time.txt into your FileServer TFTP
It works fine for SG300 and SG500. small business switches
Hope it can helps someone.
On Wednesday, January 30, 2019 at 11:55:28 AM UTC+1, Krisztián Tóth wrote:
>
> Hello,
>
> You should try, what the documentation recommends:
> "Starting with Ansible 2.5 we recommend using "connection: network_cli"
> and "become: yes" with "become_pass""
>
> From the error, that is clear you have privilege escalation problem:
> " ansible.module_utils.connection.ConnectionError: operation requires
> privilege escalation "
>
> Other deprecated features are used like "provider" and "authorize".
> See here
> <https://docs.ansible.com/ansible/latest/modules/ios_command_module.html>.
>
> Bye,
> Krisztian
>
> Jean berjonneau <[email protected] <javascript:>> ezt írta (időpont:
> 2019. jan. 30., Sze, 8:59):
>
>> Hello,
>>
>> thanks for your answer, actually when i do this with "show clock" it
>> works fine.
>> Taking your advice i tried, this is my ne
>> - name: IOS | Datadump + Show run
>> ios_config:
>> authorize: yes
>> provider: "{{ provider }}"
>> commands:
>> - terminal datadump
>> register: showrun
>>
>> And it answered back with more errors than before....
>>
>> 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
>> }
>>
>>
>> --
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/ba3903bb-1080-4273-b177-b90fa6de8fc9%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/ba3903bb-1080-4273-b177-b90fa6de8fc9%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/6279b909-0288-4902-b823-02171ea0add8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.