AnsibleでCumulusのコンフィグバックアップを取得する。
事前準備
以下の機器やAnsibleがインストールされているサーバを用意する。
- Ansibleホストサーバの立ち上げ(CentOS7)
- Cumulus機の用意
- Ansibleのインストール
AnsibleホストサーバのOS情報
# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
Cumulus機の情報
$ cat /etc/os-release | grep VERSION VERSION_ID=3.6.0 VERSION="Cumulus Linux 3.6.0" $
Ansibleバージョン
# ansible --version ansible 2.4.2.0
作業ディレクトリ構造
etc/ ┗ansible/ ┃ ┠hosts ┃ ┠save ┃ ┗show_conf_cumulus.yaml
hosts/show_run_cisco.yamlの内容
- hosts
[cumulus] 192.168.2.1
- hosts: cumulus become: yes tasks: - name: Shell Script shell: net show confi com > /home/cumulus/config.txt - name: Fetch config.txt fetch: dest=/etc/ansible/save/{{ inventory_hostname }}/config.txt src=/home/cumulus/config.txt flat=yes - name: Fetch ports.conf fetch: dest=/etc/ansible/save/{{ inventory_hostname }}/ports.conf src=/etc/cumulus/ports.conf flat=yes - name: Fetch interfaces Configuration fetch: dest=/etc/ansible/save/{{ inventory_hostname }}/interfaces src=/etc/network/interfaces flat=yes - name: Fetch FRR daemons file fetch: dest=/etc/ansible/save/{{ inventory_hostname }}/daemons src=/etc/frr/daemons flat=yes - name: Fetch frr.conf fetch: dest=/etc/ansible/save/{{ inventory_hostname }}/frr.conf src=/etc/frr/frr.conf flat=yes vars: cli: host: "{{ inventory_hostname }}" username: cumulus password: cumulus authorize: true ** 実行結果 >|| [root@localhost ansible]# ansible-playbook show_conf_cumulus.yaml PLAY [cumulus] ******************************************************************************************** TASK [Gathering Facts] ************************************************************************************ ok: [192.168.2.1] TASK [Shell Script] *************************************************************************************** changed: [192.168.2.1] TASK [Fetch config.txt] *********************************************************************************** ok: [192.168.2.1] PLAY RECAP ************************************************************************************************ 192.168.2.1 : ok=3 changed=1 unreachable=0 failed=0 [root@localhost ansible]#
バックアップコンフィグも保存確認
# ls save/192.168.2.15/* save/192.168.2.1/config.txt save/192.168.2.1/interfaces save/192.168.2.1/daemons save/192.168.2.1/ports.conf save/192.168.2.1/frr.conf #