Forum Discussion

cwkim's avatar
cwkim
Icon for Nimbostratus rankNimbostratus
Jul 24, 2019

[ANSIBLE] How do I save config file by using playbook?!

Hi, I looking for some solution about ansible-playbook...

 

I write like this...

##########################################################################

---

 

- name: 04-playbook

 hosts: ltm01

 connection: local

 

 vars:

  provider:

   password: password

   server: "{{ inventory_hostname }}"

   user: admin

   validate_certs: no

   server_port: 443

 

 tasks:

  - name: Collection Backup Data

   bigip_command:

     provider: "{{ provider }}"

     commands:

       - list net route

       - list net self

       - list net vlan

       - list sys management-ip

       - show ltm node

       - show ltm pool members

       - show ltm virtual

       - show net interface

       - show sys cpu

       - show sys disk

       - show sys failover

       - show sys hardware

       - show sys memory

       - show sys version

       - show sys service

       - show sys service ntpd

   register: output

   delegate_to: localhost

 

#  - name: Backup LTM Status

#   copy:

#     content: '{{ output.stdout_lines }}'

#     dest: /etc/ansible/F5-ansible/Backup_{{ inventory_hostname }}.txt

 

  - local_action: copy content={{ output }} dest=/etc/ansible/F5-ansible/Backup_{{ inventory_hostname }}.txt

 

#  - name: Display Backup Data

#   debug:

#    var: config_perf.stdout_lines

#   delegate_to: localhost

 

  - name: Backup bigip_base Config

   command: "cat /config/bigip_base.conf"

   register: output_1

 

  - local_action: copy content={{ output_1.stdout }} dest=/etc/ansible/F5-ansible/Backup_{{ inventory_hostname }}_bigip_base.conf

 

  - name: Backup bigip Config

   command: "cat /config/bigip.conf"

   register: output_2

 

  - local_action: copy content={{ output_2.stdout }} dest=/etc/ansible/F5-ansible/Backup_{{ inventory_hostname }}_bigip.conf

 

  - name: Backup LTM Log

   command: "cat /var/log/ltm"

   register: output_3

 

  - local_action: copy content={{ output_3.stdout }} dest=/etc/ansible/F5-ansible/Backup_{{ inventory_hostname }}_ltm.log

 

##########################################################################

 

I could get "output", but cannot get "output_1 / 2 / 3"....

(see the Bold string above it.)

 

I guess the reason that is SSH Command.. Because I use HTTPS to use ansible.

 

Is it right?!

 

And I down know how is resolve it....

 

Plz help me...

 

 

 

No RepliesBe the first to reply