diff --git a/dnaclab_linux/get_logs.yml b/dnaclab_linux/get_logs.yml index a4f386a..852b7f1 100644 --- a/dnaclab_linux/get_logs.yml +++ b/dnaclab_linux/get_logs.yml @@ -9,11 +9,11 @@ ansible.builtin.shell: "cd /var/log; find . -maxdepth 1 -type f | cut -d'/' -f2" register: files_to_copy - - name: Copy the log files - ansible.builtin.fetch: - src: /var/log/{{ item }} - dest: /home/vlad/Desktop/ansible/dnaclab_linux/logs/ - with_items: "{{ files_to_copy.stdout_lines }}" + # - name: Copy the log files + # ansible.builtin.fetch: + # src: /var/log/{{ item }} + # dest: /home/vlad/Desktop/ansible/dnaclab_linux/logs/ + # with_items: "{{ files_to_copy.stdout_lines }}" diff --git a/testing/inner.yml b/testing/inner.yml new file mode 100644 index 0000000..b3683dd --- /dev/null +++ b/testing/inner.yml @@ -0,0 +1,7 @@ +- name: Print outer and inner items + ansible.builtin.debug: + msg: "outer item={{ outer_item }} inner item={{ item }}" + loop: + - a + - b + - c \ No newline at end of file diff --git a/testing/variable-test.yml b/testing/variable-test.yml new file mode 100644 index 0000000..e4e1620 --- /dev/null +++ b/testing/variable-test.yml @@ -0,0 +1,85 @@ +- name: Testing how to access variables + hosts: localhost + gather_facts: false + vars: + test_1: + - name: vlan 20 + id: 20 + svi_ip_peer_1: 192.168.77.1/24 + svi_ip_peer_2: 192.168.77.2/24 + portchannel_id: 20 + portchannel_interfaces_peer_1: + name: port-channel20 + members: + - Eth1/5 + - Eth1/6 + mode: on + switchport_mode: access + portchannel_interfaces_peer_2: + name: port-channel20 + members: + - Eth1/5 + - Eth1/6 + mode: on + switchport_mode: access + hsrp_group: 20 + hsrp_vip: 192.168.77.254 + hsrp_preempt: enabled + hsrp_priority_peer_1: 105 + hsrp_priority_peer_2: 100 + - name: vlan 30 + id: 20 + svi_ip_peer_1: 192.168.77.1/24 + svi_ip_peer_2: 192.168.77.2/24 + portchannel_id: 20 + portchannel_interfaces_peer_1: + name: port-channel20 + members: + - Eth1/7 + - Eth1/8 + mode: on + switchport_mode: access + portchannel_interfaces_peer_2: + name: port-channel20 + members: + - Eth1/7 + - Eth1/8 + mode: on + switchport_mode: access + hsrp_group: 20 + hsrp_vip: 192.168.77.254 + hsrp_preempt: enabled + hsrp_priority_peer_1: 105 + hsrp_priority_peer_2: 100 + test_2: "{{ test_1 | map(attribute='portchannel_interfaces_peer_1') | map(attribute='members') }}" + + tasks: + + - name: Print var + ansible.builtin.debug: + var: test_2 + + - name: Print "portchannel_interfaces_peer_1" + ansible.builtin.debug: + msg: "{{ item }}" + loop: + "{{ test_1 | map(attribute='portchannel_interfaces_peer_1')}}" + + - name: Print "members" + ansible.builtin.debug: + msg: "{{ item }}" + loop: + "{{ test_1 | map(attribute='portchannel_interfaces_peer_1') | map(attribute='members')}}" + + # - name: Set members peer 1 + # ansible.builtin.set_fact: + # peer_1_vpc_interfaces: "{{ item }}" + # cacheable: yes + # loop: + # "{{ test_1 | map(attribute='portchannel_interfaces_peer_1') | map(attribute='members') }}" + + - name: Print member interfaces + ansible.builtin.debug: + msg: "{{ item[1] }}" + loop: + "{{ test_1 | map(attribute='portchannel_interfaces_peer_1') | subelements('members') }}" \ No newline at end of file