ODL Neon SR1 upgrade
[appc/deployment.git] / playbook / ansible_vfw_distributetraffic@0.00.yml
1 ---
2 - hosts: all
3   gather_facts: no
4   tasks:
5     - include_vars: "{{ ConfigFileName }}"
6     - debug: var=fwIp
7       failed_when: fwIp is not defined
8     - debug: var=sinkIp
9       failed_when: sinkIp is not defined
10     - name: Read PKG IP
11       shell: cat /opt/config/vpg_private_ip_0.txt
12       register: pkgIp
13       become: true
14     - name: Read OLD FW IP
15       shell: cat /opt/config/fw_ipaddr.txt
16       register: oldFwIp
17       become: true
18     - name: Read OLD SINK IP
19       shell: cat /opt/config/sink_ipaddr.txt
20       register: oldSinkIp
21       become: true
22     - name: Read protected net CIDR
23       shell: cat /opt/config/protected_net_cidr.txt
24       register: protectedCidr
25       become: true
26     - debug: var=pkgIp.stdout
27     - debug: var=oldFwIp.stdout
28     - debug: var=oldSinkIp.stdout
29     - debug: var=protectedCidr.stdout
30     - debug: 
31         msg: "FW IP has not been changed"
32       when: oldFwIp.stdout == fwIp
33     - block:
34         - name: Remove OLD FW IP route
35           shell: vppctl ip route del {{ protectedCidr.stdout }} via {{ oldFwIp.stdout }}
36         - name: Add NEW FW IP route
37           shell: vppctl ip route add {{ protectedCidr.stdout }} via {{ fwIp }}
38         - name: Save NEW FW IP address
39           shell: echo {{ fwIp }} > /opt/config/fw_ipaddr.txt
40         - debug: 
41             msg: "FW IP has been changed"
42       become: true
43       when: oldFwIp.stdout != fwIp
44     - debug: 
45         msg: "SINK IP has not been changed"
46       when: oldSinkIp.stdout == sinkIp
47     - block:
48         - block:
49           - name: Modify packet stream files
50             debug:
51               msg: "Modify packet stream files"
52           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp1"
53           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp2"
54           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp3"
55           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp4"
56           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp5"
57           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp6"
58           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp7"
59           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp8"
60           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp9"
61           - shell: "sed -i -e '0,/UDP/ s/UDP:.*/UDP: {{ pkgIp.stdout }} -> {{ sinkIp }}/' /opt/pg_streams/stream_fw_udp10"
62         - block:
63           - name: Delete old streams
64             debug:
65               msg: "Delete old streams"
66           - shell: vppctl packet-generator delete fw_udp1
67           - shell: vppctl packet-generator delete fw_udp2
68           - shell: vppctl packet-generator delete fw_udp3
69           - shell: vppctl packet-generator delete fw_udp4
70           - shell: vppctl packet-generator delete fw_udp5
71           - shell: vppctl packet-generator delete fw_udp6
72           - shell: vppctl packet-generator delete fw_udp7
73           - shell: vppctl packet-generator delete fw_udp8
74           - shell: vppctl packet-generator delete fw_udp9
75           - shell: vppctl packet-generator delete fw_udp10
76         - block:
77           - name: Install new streams
78             debug:
79               msg: "Install new streams"
80           - shell: vppctl exec /opt/pg_streams/stream_fw_udp1
81           - shell: vppctl exec /opt/pg_streams/stream_fw_udp2
82           - shell: vppctl exec /opt/pg_streams/stream_fw_udp3
83           - shell: vppctl exec /opt/pg_streams/stream_fw_udp4
84           - shell: vppctl exec /opt/pg_streams/stream_fw_udp5
85           - shell: vppctl exec /opt/pg_streams/stream_fw_udp6
86           - shell: vppctl exec /opt/pg_streams/stream_fw_udp7
87           - shell: vppctl exec /opt/pg_streams/stream_fw_udp8
88           - shell: vppctl exec /opt/pg_streams/stream_fw_udp9
89           - shell: vppctl exec /opt/pg_streams/stream_fw_udp10
90         - block:
91           - name: Enable new streams
92             debug:
93               msg: "Enable new streams"
94           - shell: vppctl packet-generator enable fw_udp1
95           - shell: vppctl packet-generator enable fw_udp2
96           - shell: vppctl packet-generator enable fw_udp3
97           - shell: vppctl packet-generator enable fw_udp4
98           - shell: vppctl packet-generator enable fw_udp5
99           - shell: vppctl packet-generator enable fw_udp6
100           - shell: vppctl packet-generator enable fw_udp7
101           - shell: vppctl packet-generator enable fw_udp8
102           - shell: vppctl packet-generator enable fw_udp9
103           - shell: vppctl packet-generator enable fw_udp10
104         - name: Save NEW SINK IP address
105           shell: echo {{ sinkIp }} > /opt/config/sink_ipaddr.txt
106         - debug: 
107             msg: "SINK IP has been changed"
108       become: true
109       when: oldSinkIp.stdout != sinkIp
110