|
9 | 9 |
|
10 | 10 | - name: Set SONiC backplane port name |
11 | 11 | set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int + 1 }}" |
| 12 | + when: '"hwsku" not in configuration[hostname]' |
| 13 | + |
| 14 | +- name: Set SONiC backplane port name for cisco-8101-p4-32x100-vs |
| 15 | + set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int *4 }}" |
| 16 | + when: '"hwsku" in configuration[hostname] and configuration[hostname]["hwsku"]=="cisco-8101-p4-32x100-vs"' |
12 | 17 |
|
13 | 18 | - set_fact: |
14 | 19 | mgmt_ip: "{{ ansible_host }}/{{ mgmt_prefixlen }}" |
15 | 20 | mgmt_gw: "{{ vm_mgmt_gw | default(mgmt_gw) }}" |
16 | 21 |
|
17 | | -- name: create mgmt config |
18 | | - template: src="configdb-mgmt.j2" |
19 | | - dest=config-mgmt.json |
20 | | - when: hostname in configuration |
21 | | - |
22 | | -- name: create device metadata config |
23 | | - shell: > |
24 | | - sonic-cfggen -H -k Force10-S6000 --preset empty |
25 | | - | jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"' |
26 | | - | jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"' |
27 | | - | jq '.DEVICE_METADATA.localhost.deployment_id="1"' |
28 | | - > config-metadata.json |
29 | | - when: hostname in configuration |
30 | | - |
31 | | -- name: create interface config |
32 | | - shell: > |
33 | | - sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data |
34 | | - | jq '.PORT[].admin_status |= "up"' |
35 | | - > config-port.json |
36 | | - when: hostname in configuration |
37 | | - |
38 | | -- name: create topo config |
39 | | - template: src="configdb.j2" |
40 | | - dest=config-topo.json |
41 | | - when: hostname in configuration |
42 | | - |
43 | | -- name: create config db json |
44 | | - shell: | |
45 | | - set -e |
46 | | - sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json |
47 | | - rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json |
48 | | - become: yes |
49 | | - when: hostname in configuration |
50 | | - notify: |
51 | | - - Update config db |
52 | | - - wait for SONiC update config db to finish |
| 22 | +- name: create config via mininet config |
| 23 | + block: |
| 24 | + - name: create mgmt config |
| 25 | + template: src="configdb-mgmt.j2" |
| 26 | + dest=config-mgmt.json |
| 27 | + |
| 28 | + - name: create device metadata config for {{ configuration[hostname]['hwsku'] }} |
| 29 | + shell: > |
| 30 | + sonic-cfggen -H -k {{ configuration[hostname]['hwsku'] }} --preset empty |
| 31 | + | jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"' |
| 32 | + | jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"' |
| 33 | + | jq '.DEVICE_METADATA.localhost.deployment_id="1"' |
| 34 | + > config-metadata.json |
| 35 | + when: '"hwsku" in configuration[hostname]' |
| 36 | + |
| 37 | + - name: create device metadata config |
| 38 | + shell: > |
| 39 | + sonic-cfggen -H -k Force10-S6000 --preset empty |
| 40 | + | jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"' |
| 41 | + | jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"' |
| 42 | + | jq '.DEVICE_METADATA.localhost.deployment_id="1"' |
| 43 | + > config-metadata.json |
| 44 | + when: '"hwsku" not in configuration[hostname]' |
| 45 | + |
| 46 | + - name: create interface config for {{ configuration[hostname]['hwsku'] }} |
| 47 | + shell: > |
| 48 | + sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/{{ configuration[hostname]['hwsku'] }}/port_config.ini -k {{ configuration[hostname]['hwsku'] }} --print-data |
| 49 | + | jq '.PORT[].admin_status |= "up"' |
| 50 | + > config-port.json |
| 51 | + when: '"hwsku" in configuration[hostname]' |
| 52 | + |
| 53 | + - name: create interface config |
| 54 | + shell: > |
| 55 | + sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data |
| 56 | + | jq '.PORT[].admin_status |= "up"' |
| 57 | + > config-port.json |
| 58 | + when: '"hwsku" not in configuration[hostname]' |
| 59 | + |
| 60 | + - name: create topo config |
| 61 | + template: src="configdb.j2" |
| 62 | + dest=config-topo.json |
| 63 | + |
| 64 | + - name: create config db json |
| 65 | + shell: | |
| 66 | + set -e |
| 67 | + sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json |
| 68 | + rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json |
| 69 | + become: yes |
| 70 | + notify: |
| 71 | + - Update config db |
| 72 | + - wait for SONiC update config db to finish |
| 73 | + when: hostname in configuration and "init_cfg_profile" not in configuration[hostname] |
| 74 | + |
| 75 | +- name: Update config via provided json |
| 76 | + block: |
| 77 | + - name: Get playbook directory |
| 78 | + debug: |
| 79 | + msg: "The playbook dir {{ playbook_dir }}" |
| 80 | + - name: Load variables from vars/init_cfg_profiles.yml |
| 81 | + include_vars: "vars/init_cfg_profiles.yml" |
| 82 | + - name: set cfg_profile to {{ configuration[hostname].init_cfg_profile }} |
| 83 | + set_fact: |
| 84 | + cfg_profile: "{{ configuration[hostname].init_cfg_profile }}" |
| 85 | + - name: Set actual configuration value based on cfg_profile key |
| 86 | + set_fact: |
| 87 | + actual_config: "{{ lookup('vars', cfg_profile) }}" |
| 88 | + - name: Debug actual configuration value |
| 89 | + debug: |
| 90 | + msg: "The actual configuration value is: {{ actual_config }}" |
| 91 | + - name: Copy over config_db.json from file system |
| 92 | + copy : |
| 93 | + src: "{{ playbook_dir }}/{{ actual_config }}" |
| 94 | + dest: /tmp/config_db.json |
| 95 | + - name: Overwrite config_db.json |
| 96 | + shell: cat /tmp/config_db.json > /etc/sonic/config_db.json |
| 97 | + become: yes |
| 98 | + notify: |
| 99 | + - Update config db |
| 100 | + - wait for SONiC update config db to finish |
| 101 | + when: hostname in configuration and configuration[hostname]['init_cfg_profile'] is defined |
53 | 102 |
|
54 | 103 | - name: Load PTF image |
55 | 104 | block: |
|
0 commit comments