我是所有 Ansible 的新手。所以大部分时间我都处于“试错”模式。
现在我正面临着一本剧本的挑战,我不知道该往下看。
该剧本的主要任务应该是从 Cisco 设备获取“显示运行”并将其保存在备份服务器(远程服务器)上的文本文件中。
唯一不工作的任务是备份任务。
这是我的剧本:
- hosts: IOSGATEWAY
gather_facts: no
connection: local
tasks:
- name: GET CREDENTIALS
include_vars: path/to/all/all.yml
- name: DEFINE CONNECTION TO GW
set_fact:
connection:
host: "{{ inventory_hostname }}"
username: "{{ creds['username'] }}"
password: "{{ creds['password'] }}"
- name: GET SHOW RUN
ios_command:
provider: "{{ connection }}"
commands:
- show run
register: show_run
- name: SAVE TO BACKUP SERVER
copy:
content: "{{ show_run.stdout[0] }}"
dest: "path/to/Directory/{{ inventory_hostname }}.txt"
delegate_to: BACKUPSERVER
有人可以提示我正确的方向吗?