- Table of Contents
- Related Documents
-
| Title | Size | Download |
|---|---|---|
| 01-Text | 144.71 KB |
Contents
Installing the SeerEngine-DC Ansible plug-in
Setting up the basic environment
Installing, uninstalling, and upgrading the Ansible plug-in
Installing the Ansible plug-in
Uninstalling the Ansible plug-in
Overview
Ansible, an automated operations and maintenance tool programmed in Python, allows for bulk system configuration, program deployment, and command execution.
The SeerEngine-DC Ansible plug-in provides customized modules that can synchronize the plays in Ansible playbooks to the SeerEngine-DC controller through the RESTful API.
The SeerEngine-DC Ansible plug-in provides the following customized modules:
Table 1 Customized modules and functions of Ansible plug-ins
|
Module name |
Function |
|
device |
Creates or deletes devices. |
|
downlinkport |
Creates or deletes downlink interfaces. |
|
fabric |
Creates or deletes fabrics. |
|
gateway |
Creates or deletes border gateways. |
|
gateway_member |
Creates or deletes gateway members. |
|
group |
Creates or deletes device groups. |
|
group_member |
Creates or deletes device group members. |
|
interface |
Manages device interface status. |
|
ip_pool |
Creates or deletes IP address pools. |
|
network |
Creates or deletes vNetworks. |
|
port |
Creates or deletes vPorts. |
|
port_vlan_domain_binding |
Creates or deletes VLAN/QinQ-VXLAN mapping table-to-interface bindings. |
|
pvid |
Creates or deletes PVIDs. |
|
pvlan |
Creates or deletes PVLAN mappings. |
|
qos |
Creates or deletes network policies. |
|
router |
Creates or deletes vRouters. |
|
security_group |
Creates or deletes security groups. |
|
subnet |
Creates or deletes vSubnets. |
|
tenant |
Creates or deletes tenants. |
|
vlan_domain |
Creates or deletes VLAN/QinQ-VXLAN mapping tables. |
|
vlan_domain_binding |
Creates or deletes VLAN/QinQ-VXLAN mapping table-to-device bindings. |
|
vlan_pool |
Creates or deletes VLAN address pools. |
|
vxlan_pool |
Creates or deletes VXLAN address pools. |
Preparing for installation
Hardware requirements
Table 2 shows the minimum hardware requirements for installing the SeerEngine-DC Ansible plug-in on a physical server or virtual machine.
Table 2 Minimum hardware requirements
|
CPU |
Memory size |
Drive size |
|
One core |
2 GB |
5 GB |
Software requirements
The SeerEngine-DC Ansible plug-in can operate only on the CentOS 7 series and CentOS 8 series operating systems.
Installing the SeerEngine-DC Ansible plug-in
The SeerEngine-DC Ansible plug-in operates based on Python3. Make sure the operating system is installed with Python3.6 or its later versions.
Setting up the basic environment
Before installing the plug-in, set up the basic environment first.
To set up the basic environment:
1. Download and install the Ansible installation package online.
[root@localhost ~]# pip3 install ansible
|
CAUTION: Make sure the Ansible installation package is in version 2.10.0 or later. |
2. Install the requests package.
[root@localhost ~]# pip3 install requests
Installing, uninstalling, and upgrading the Ansible plug-in
Installing the Ansible plug-in
Obtaining the plug-in installation package
Obtain the SeerEngine-DC Ansible package of the required version and then save the package to the target installation directory on the target server or virtual machine.
Alternatively, transfer the installation package to the target installation directory through a file transfer protocol such as FTP, TFTP, or SCP. Use the binary transfer mode to prevent the software package from being corrupted during transit.
Installing the Ansible plug-in
Access the directory where the SeerEngine-DC Ansible package (a .tar.gz file) is saved, and install the package. In the following example, the SeerEngine-DC Ansible package is saved to the /root directory. The name of the package is SeerEngine_DC-ANSIBLE_PLUGIN-version1.tar.gz. version1 represents the version of the package.
[root@localhost ~]# ansible-galaxy collection install SeerEngine_DC-ANSIBLE_PLUGIN-E6203.tar.gz
Verifying the installation
Verify that the SeerEngine-DC Ansible package is correctly installed. If the correct software version is displayed, the package is installed successfully.
[root@localhost ~]# ansible-galaxy collection list | grep h3c
h3c.sdn 2.0.0
Uninstalling the Ansible plug-in
1. Identify the path where the plug-in is saved.
[root@localhost ~]# find / -name h3c
/root/.ansible/collections/ansible_collections/h3c
2. Remove the code block from the path.
[root@localhost ~] rm -rf /root/.ansible/collections/ansible_collections/h3c
3. Verify that the plug-in is uninstalled successfully. If no result is displayed, the plug-in is uninstalled successfully.
[root@localhost ~]# ansible-galaxy collection list | grep h3c
Upgrading the Ansible plug-in
To upgrade the SeerEngine-DC Ansible plug-in, you must uninstall the current version first, and install the new version. For information about installing the SeerEngine-DC Ansible plug-in, see "Uninstalling the Ansible plug-in." For information about uninstalling the SeerEngine-DC Ansible plug-in, see "Installing the Ansible plug-in."
Creating playbooks
|
CAUTION: SeerEngine-DC performs a fuzzy match when it searches for resources through the RESTful API. For example, if you use an Ansible playbook to delete a vNetwork resource named net1, all vNetworks whose name contains net1, for example, net12 and net123 are matched and will also be deleted. To avoid such issues, Ansible requires that the names of the resources not be inclusive of each other. |
Create a playbook in the format of xxx.yaml. When you run a playbook, the system calls a specific custom module defined in that playbook.
For sample playbooks, see H3C SeerEngine-DC Ansible Plug-In Resource Management.
Restrictions and guidelines
For a required parameter, you must enter the parameter and its value in the playbook. For an optional parameter, if you do not specify a value for it, the system uses the default value, if any. Other parameters are common parameters defined by Ansible. You specify the parameters by following the examples.
Running playbooks
To run a playbook, execute the ansible-playbook xxx.yaml command. The following example runs the playbook named h3c_network.yaml.
[root@localhost ~]# ansible-playbook h3c_network.yaml
Alternatively, execute the following command to run the playbook and obtain the return values:
[root@ansible h3c_ansible]# ansible-playbook h3c_network.yaml -vvv
ansible-playbook [core 2.13.1]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.9.5 (default, Aug 16 2021, 11:00:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
jinja version = 3.0.1
libyaml = True
No config file found; using defaults
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: h3c_network.yaml ********************************************************************************************************************
1 plays in h3c_network.yaml
PLAY [network] ********************************************************************************************************************************
META: ran handlers
TASK [h3c.sdn.network] ************************************************************************************************************************
task path: /root/h3c_ansible/h3c_network.yaml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833 `" && echo ansible-tmp-1691488016.8046002-8167-67155530079833="` echo /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/h3c/sdn/plugins/modules/network.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-8162v6bqph85/tmp20tlkd7y TO /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833/AnsiballZ_network.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833/ /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833/AnsiballZ_network.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.9 /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833/AnsiballZ_network.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1691488016.8046002-8167-67155530079833/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"invocation": {
"module_args": {
"admin_state_up": true,
"auth": {
"password": "Pwd@12345",
"url": "https://99.0.92.90:30000",
"username": "admin"
},
"external": false,
"force_flat": false,
"mtu": 100,
"name": "ansible_network4",
"provider_network_type": "VXLAN",
"provider_physical_network": null,
"provider_segmentation_id": 238,
"shared": false,
"state": "present",
"tenant_name": "ironic-inspect"
}
},
"network": {
"networks": [
{
"admin_state_up": true,
"arp_ctrl": {
"arp_flooding": "DEFAULT",
"arp_mac_learning": "DEFAULT",
"arp_proxy": "DEFAULT",
"arp_to_controller": "DEFAULT"
},
"arp_send_rate": 0,
"auto_port_creation": "DEFAULT",
"bum_restrain_ctrl": {
"broadcast_value": null,
"multicast_value": null,
"unknownunicast_value": null
},
"cloud_region_name": null,
"dhcp_ctrl": {
"dhcp_to_controller": "DEFAULT"
},
"dhcp_host_group_id": null,
"dhcp_relay": null,
"dhcpv6_ctrl": {
"dhcpv6_to_controller": "DEFAULT"
},
"dhcpv6_ctrl": {
"preferred_lifetime": 7,
"valid_lifetime": 30
},
"disable_gateway": false,
"distributed": true,
"export_rts": [
"1:238"
],
"external:l3vni": null,
"floodingdisable_ctrl": {
"broadcast": "DEFAULT",
"multicast": "DEFAULT",
"unknownunicast": "DEFAULT"
},
"force_flat": false,
"gateway_list": [],
"id": "a58e4318-36cf-406f-ac35-bdfe33dc434b",
"import_rts": [
"1:238"
],
"lldp_ctrl": {
"active_port": "DEFAULT"
},
"mac_address_learning": "ENABLE",
"mac_advertising": "DEFAULT",
"mtu": 100,
"multicast_ctrl": {
"multicast_enable": false,
"multicast_enable_ipv6": false
},
"name": "ansible_network4",
"nd_ctrl": {
"nd_mac_learning": "DEFAULT",
"nd_proxy": "DEFAULT",
"nsna_flooding": "DEFAULT",
"nsna_to_controller": "DEFAULT",
"rsra_flooding": "DEFAULT",
"rsra_to_controller": "DEFAULT"
},
"origin": null,
"pre_cfg": "false",
"primary_network_id": null,
"provider:domain": "ffffffff-0000-0000-0000-000000000001",
"provider:network_type": "VXLAN",
"provider:original_network_type": null,
"provider:physical_network": null,
"provider:segmentation_id": 238,
"qos_id": null,
"ra_timers": {
"router_lifetime": 1800
},
"rarp_ctrl": {
"rarp_flooding": "DEFAULT",
"rarp_to_controller": "DEFAULT"
},
"redistribute_external_routes": false,
"reduce_routes": false,
"router:external": false,
"router_ids": [],
"segments": [],
"shared": false,
"statistical_information": null,
"status": "ACTIVE",
"subnets": [],
"tenant_id": "d4fd640e-3943-42ba-9d7e-f2317343aaa7",
"tenant_name": "ironic-inspect",
"vds_name": "VDS1",
"vlan_transparent": "false",
"vpninstance_name": null,
"vsi_mac": null,
"vswitch_flood": "DEFAULT",
"vswitch_flood_and_learn": "DEFAULT",
"vswitch_learn": "DEFAULT"
}
]
}
}
META: ran handlers
META: ran handlers
PLAY RECAP ************************************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

