Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Fabric Lifecycle Management Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Managing Custom Roles

date_range 07-Jun-23

These topics provide instructions to add custom roles, backup custom roles, and restore custom roles.

Adding Custom Roles

Follow these steps to add a custom overlay role to device(s) managed by Contrail Enterprise Multicloud (CEM).

  1. Run the following command from the server running the device manager container.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 bash
  2. Define the custom role object in predef_payloads.json.
    content_copy zoom_out_map
    (config-device-manager) # vi /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json
  3. Define custom overlay roles.

    All roles are defined in the “data”->"object_type": "overlay-role", "objects": [ section. As an example, motd-test is defined as a custom overlay role.

    content_copy zoom_out_map
    "object_type": "overlay-role",
      	"objects": [
        	{
          	"fq_name": [
            	"default-global-system-config", "motd-test"
          	],
          	"name": "motd-test"
        	},
  4. After the roles are defined, map the custom role to devices and underlay roles.

    All device profiles are listed in the “data”->"object_type": "node-profile" section. Custom roles are added in the node_profile_roles -> role_mappings section.

    As an example, add motd-test custom role to juniper-mx device that is already configured with leaf physical role.

    content_copy zoom_out_map
    {
          	"fq_name": [
            	"default-global-system-config", "juniper-mx"
          	],
          	"name": "juniper-mx",
          	"node_profile_vendor": "Juniper",
          	"node_profile_device_family": "junos",
          	"node_profile_hitless_upgrade": true,
          	"node_profile_roles": {
            	"role_mappings": [
              	{
                	"physical_role": "leaf",
                	"rb_roles": ["CRB-Access", "CRB-Gateway", "DC-Gateway", "Route-Reflector", "DCI-Gateway", "ERB-UCAST-Gateway", "DCI-Gateway", "CRB-MCAST-Gateway", "PNF-Servicechain", "AR-Client", "motd-test"]
              	},
              	{
                	"physical_role": "spine",
                	"rb_roles": ["lean", "CRB-Access", "CRB-Gateway", "DC-Gateway", "Route-Reflector", "CRB-MCAST-Gateway", "DCI-Gateway", "PNF-Servicechain", "AR-Client"]
              	}
            	]
          	}
        	}
  5. Edit the all.yml file.
    content_copy zoom_out_map
    (config-device-manager) # vi /opt/contrail/fabric_ansible_playbooks/group_vars/all.yml
  6. Create a directory, motd_test, and configure motd-test as leaf physical role in the feature_based_plugin_roles section of the all.yml file.

    The Jinja template for each custom role and underlay role is stored in this directory.

    content_copy zoom_out_map
    feature_based_plugin_roles:
      motd-test@leaf:
    	- motd_test
      CRB-Access@leaf:
    	- overlay_storm_control
    	- overlay_telemetry
    
    Note:

    The name of the directory is motd_test. The name of the custom role is motd-test.

  7. Add the motd_test directory to the configuration apply order in the feature_apply_order section.
    content_copy zoom_out_map
    feature_apply_order:
      - basic
      - underlay_ip_clos
     [...]
      - overlay_telemetry
      - motd_test
  8. Add Jinja templates.

    The device configuration templates are located here:

    content_copy zoom_out_map
    /opt/contrail/fabric_ansible_playbooks/config_templates/ 

    Create motd_test directory.

    content_copy zoom_out_map
    (config-device-manager) # cd /opt/contrail/fabric_ansible_playbooks/config_templates/
    (config-device-manager) # mkdir motd_test
    (config-device-manager) # cd motd_test
  9. Add custom role to a device.

    The configuration file name depends on the device type. In this example, the file name for the devices are as follows:

    • MX Series devices: juniper_junos_motd_test.j2

    • QFX Series devices: juniper_junos-qfx_motd_test.j2

    Create a configuration file, juniper_junos_motd_test.j2, to add a custom role for the MX series device.

    content_copy zoom_out_map
    (config-device-manager) # vi juniper_junos_motd_test.j2
  10. Configure the file using the set command.
    content_copy zoom_out_map
    set groups {{cfg_group}} system login message MOTD_TEST

    Using{{cfg_group}} allows you to separate custom group configuration from predefined CEM roles.

  11. Exit the container and then restart it.
    content_copy zoom_out_map
    (config-device-manager) # exit
    # docker restart config_devicemgr_1
    

    The new role is now seen in the Contrail Command user interface (UI). See Figure 1.

    Figure 1: motd-test Routing-Bridging Rolemotd-test Routing-Bridging Role
  12. (Optional) After applying the role, log in to the device and confirm that the configuration is applied.
    content_copy zoom_out_map
    MX> show configuration | compare rollback 1
    [edit groups]
       __contrail_overlay_networking__ { ... }
    +  __contrail_motd_test__ {
    +  	system {
    +      	login {
    +          	message MOTD_TEST;
    +      	}
    +  	}
    +  }
    [edit]
    - apply-groups [ re0 __contrail_basic__ __contrail_underlay_ip_clos__ __contrail_underlay_infra_bms_access__ __contrail_overlay_bgp__ __contrail_overlay_evpn__ __contrail_overlay_evpn_access__ __contrail_overlay_evpn_gateway__ __contrail_overlay_evpn_type5__ __contrail_overlay_dhcp_relay__ __contrail_overlay_security_group__ __contrail_overlay_lag__ __contrail_overlay_multi_homing__ __contrail_overlay_fip_snat__ __contrail_overlay_networking__ ];
    + apply-groups [ re0 __contrail_basic__ __contrail_underlay_ip_clos__ __contrail_underlay_infra_bms_access__ __contrail_overlay_bgp__ __contrail_overlay_evpn__ __contrail_overlay_evpn_access__ __contrail_overlay_evpn_gateway__ __contrail_overlay_evpn_type5__ __contrail_overlay_dhcp_relay__ __contrail_overlay_security_group__ __contrail_overlay_lag__ __contrail_overlay_multi_homing__ __contrail_overlay_fip_snat__ __contrail_overlay_networking__ __contrail_motd_test__ ];
    

Backup and Restore Custom Roles

These topics provide instructions to backup and restore custom roles.

Backup Custom Roles

Follow these steps to backup custom roles.

  1. Backup /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 cat /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json > predef_payloads.json.bak
  2. Verify the overlay roles and node profiles.

    For example, when you back up custom roles during the upgrade process, the existing containers are removed and the custom roles are erased. You will not be able to restore these roles and configurations once it has been erased. Hence, ensure that you back up the correct file by verifying the roles and node profiles before the upgrade process.

  3. Backup all.yml.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 cat /opt/contrail/fabric_ansible_playbooks/group_vars/all.yml > all.yml.bak
  4. Verify the feature_based_plugin_roles and feature apply order sections.
  5. Backup custom roles.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 tar --exclude "overlay*" -czvf custom_roles.tar.gz /opt/contrail/fabric_ansible_playbooks/config_templates/
    # docker cp config_devicemgr_1:custom_roles.tar.gz 

    Ensure that you add --exclude before "overlay*" when you back up custom roles. If you do not add --exclude, both custom roles as well as predefined roles are backed up. This might cause any predefined roles that had bug fixes for the next release to be overwritten.

    For example, assume that there is a fix in the Jinja template for overlay_evpn predefined role for Contrail Networking Release 2005. When you upgrade Contrail Networking Release 2003 to Contrail Networking Release 2005, and subsequently use the backup file (that was backed up not using --exclude), all fixes related to predefined roles for Contrail Networking Release 2005 will be overwritten when you use the config template from the backup file.

Restore Custom Roles

Follow these steps to restore custom roles.

  1. Copy the new /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json file.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 cat /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json > predef_payloads.json.new
    
  2. Verify overlay roles and node profiles.
    content_copy zoom_out_map
    # diff -u predef_payloads.json.bak predef_payloads.json.new
    Note:

    New roles might have been added when CEM was updated.

  3. Restore the predef_payloads.json changes.
    1. Open predef_payloads.json.
      content_copy zoom_out_map
      docker exec -it config_devicemgr_1 vi /opt/contrail/fabric_ansible_playbooks/conf/predef_payloads.json
    2. Verify that all roles are defined in the “data”->"object_type": "overlay-role", "objects": [ section, and motd-test is defined as a custom overlay role.

      For more information, see the predef_payloads.json.bak file. For a file diff, refer to section two of the predef_payloads.json.bak file.

      content_copy zoom_out_map
      "object_type": "overlay-role",
        	"objects": [
          	{
            	"fq_name": [
              	"default-global-system-config", "motd-test"
            	],
            	"name": "motd-test"
          	},
    3. Verify that the custom role is mapped to devices and underlay roles.

      All device profiles are listed in the “data”->"object_type": "node-profile" section. Custom roles are added in the node_profile_roles -> role_mappings section.

      As an example, add motd-test custom role to juniper-mx device that is already configured with leaf physical role.

      content_copy zoom_out_map
      {
            	"fq_name": [
              	"default-global-system-config", "juniper-mx"
            	],
            	"name": "juniper-mx",
            	"node_profile_vendor": "Juniper",
            	"node_profile_device_family": "junos",
            	"node_profile_hitless_upgrade": true,
            	"node_profile_roles": {
              	"role_mappings": [
                	{
                  	"physical_role": "leaf",
                  	"rb_roles": ["CRB-Access", "CRB-Gateway", "DC-Gateway", "Route-Reflector", "DCI-Gateway", "ERB-UCAST-Gateway", "DCI-Gateway", "CRB-MCAST-Gateway", "PNF-Servicechain", "AR-Client", "motd-test"]
                	},
                	{
                  	"physical_role": "spine",
                  	"rb_roles": ["lean", "CRB-Access", "CRB-Gateway", "DC-Gateway", "Route-Reflector", "CRB-MCAST-Gateway", "DCI-Gateway", "PNF-Servicechain", "AR-Client"]
                	}
              	]
            	}
          	}
  4. Backup all.yml.
    content_copy zoom_out_map
    # docker exec -it config_devicemgr_1 cat /opt/contrail/fabric_ansible_playbooks/group_vars/all.yml > all.yml.new
  5. Verify changes in feature_based_plugin_roles and feature apply order.
    content_copy zoom_out_map
    # diff -u all.yml.bak all.yml.new
    Note:

    New roles might have been added when CEM was updated.

  6. Restore all.yml.

    For more information, see the all.yml.bak file. For a file diff, refer to section five of the all.yml.bak file.

    1. Open all.yml.
      content_copy zoom_out_map
      docker exec -it config_devicemgr_1 vi /opt/contrail/fabric_ansible_playbooks/group_vars/all.yml
    2. Verity that feature_based_plugin_roles has all roles and role mappings. Ensure that motd-test role is also added.
      content_copy zoom_out_map
      feature_based_plugin_roles:
        motd-test@leaf:
      	- motd_test
        CRB-Access@leaf:
      	- overlay_storm_control
      	- overlay_telemetry
      
    3. Verify that the feature_apply_order describes the order of templates that are applied on devices. Ensure that motd_test is also added.
      content_copy zoom_out_map
      feature_apply_order:
        - basic
        - underlay_ip_clos
       [...]
        - overlay_telemetry
        - motd_test
  7. Restore custom roles Jinja templates.
    content_copy zoom_out_map
    # docker cp custom_roles.tar.gz config_devicemgr_1:/ 
    # docker exec -it config_devicemgr_1 tar xzvf custom_roles.tar.gz 
    
  8. Restart the container and verify roles.
    content_copy zoom_out_map
    # docker restart config_devicemgr_1
footer-navigation