|
1 | 1 | --- |
2 | | -- name: Include variables for PTF containers |
3 | | - include_vars: |
4 | | - dir: "{{ playbook_dir }}/group_vars/ptf_host/" |
| 2 | +- name: Set ptf host |
| 3 | + set_fact: |
| 4 | + ptf_host: "{{ ptf_ip.split('/')[0] }}" |
| 5 | + |
| 6 | +- name: Add ptf host |
| 7 | + add_host: |
| 8 | + name: "{{ ptf_host }}" |
| 9 | + groups: |
| 10 | + - ptf |
| 11 | + |
| 12 | +- name: Check if ptf_tgen exists |
| 13 | + supervisorctl: |
| 14 | + name: ptf_tgen |
| 15 | + state: present |
| 16 | + become: True |
| 17 | + delegate_to: "{{ ptf_host }}" |
| 18 | + ignore_errors: True |
| 19 | + register: ptf_tgen_state |
5 | 20 |
|
6 | 21 | - block: |
7 | | - - name: Set ptf host |
8 | | - set_fact: |
9 | | - ptf_host: "ptf_{{ vm_set_name }}" |
10 | | - ptf_host_ip: "{{ ptf_ip.split('/')[0] }}" |
| 22 | + - name: Copy scapy scripts to ptf host |
| 23 | + copy: |
| 24 | + src: "{{ item }}" |
| 25 | + dest: "/ptf_tgen/" |
| 26 | + with_fileglob: |
| 27 | + - "{{ playbook_dir }}/../spytest/spytest/tgen/scapy/*" |
| 28 | + - "{{ playbook_dir }}/../spytest/spytest/dicts.py" |
11 | 29 |
|
12 | | - - name: Add ptf host |
13 | | - add_host: |
14 | | - hostname: "{{ ptf_host }}" |
15 | | - ansible_user: "{{ ptf_host_user }}" |
16 | | - ansible_ssh_host: "{{ ptf_host_ip }}" |
17 | | - ansible_ssh_pass: "{{ ptf_host_pass }}" |
18 | | - groups: |
19 | | - - ptf_host |
| 30 | + - name: Create ptf_tgen service |
| 31 | + copy: |
| 32 | + src: "/ptf_tgen/service.sh" |
| 33 | + dest: "/ptf_tgen/ptf_tgen.sh" |
| 34 | + mode: "0755" |
| 35 | + remote_src: yes |
20 | 36 |
|
21 | | - - name: Check if ptf_tgen exists |
| 37 | + - name: Start ptf_tgen |
22 | 38 | supervisorctl: |
23 | 39 | name: ptf_tgen |
24 | | - state: present |
25 | | - become: True |
26 | | - delegate_to: "{{ ptf_host }}" |
27 | | - ignore_errors: True |
28 | | - register: ptf_tgen_state |
29 | | - |
30 | | - - block: |
31 | | - - name: Copy scapy scripts to ptf host |
32 | | - copy: |
33 | | - src: "{{ item }}" |
34 | | - dest: "/ptf_tgen/" |
35 | | - with_fileglob: |
36 | | - - "{{ playbook_dir }}/../spytest/spytest/tgen/scapy/*" |
37 | | - - "{{ playbook_dir }}/../spytest/spytest/dicts.py" |
38 | | - |
39 | | - - name: Create ptf_tgen service |
40 | | - copy: |
41 | | - src: "/ptf_tgen/service.sh" |
42 | | - dest: "/ptf_tgen/ptf_tgen.sh" |
43 | | - mode: "0755" |
44 | | - remote_src: yes |
45 | | - |
46 | | - - name: Start ptf_tgen |
47 | | - supervisorctl: |
48 | | - name: ptf_tgen |
49 | | - state: restarted |
50 | | - become: True |
51 | | - delegate_to: "{{ ptf_host }}" |
52 | | - when: ptf_tgen_state is not failed |
53 | | - when: |
54 | | - - ptf_host_user is defined |
55 | | - - ptf_host_pass is defined |
| 40 | + state: restarted |
| 41 | + become: True |
| 42 | + delegate_to: "{{ ptf_host }}" |
| 43 | + when: ptf_tgen_state is not failed |
0 commit comments