• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C 园区盒式交换机典型配置举例-6W100

目录

62-Puppet典型配置举例

本章节下载 62-Puppet典型配置举例  (156.89 KB)

docurl=/cn/Service/Document_Software/Document_Center/Home/Switches/00-Public/Configure/Typical_Configuration_Example/H3C_CE-B70D022-6W100/202012/1371487_30005_0.htm

62-Puppet典型配置举例


1 简介

本文档介绍了Puppet的配置举例。

Puppet是开源的配置管理工具,用户使用Puppet语言将需要对设备进行的配置写成脚本,并保存到服务器中,再通过服务器把这些配置脚本下发到各网络设备,实现对网络设备的集中配置管理。

2 配置前提

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文假设您已了解Puppet特性。

3 Puppet典型配置举例

3.1  组网需求

图3-1所示,Device A和B作为Puppet agent与Puppet master相连。

要求通过Puppet在所有Puppet agent上创建ID为100的VLAN。

图3-1 Puppet配置组网图

 

3.2  适用产品及版本

表3-1 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

不支持

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

不支持

S5120V2-SI系列

S5120V2-LI系列

不支持

S3100V3-EI系列

S3100V3-SI系列

不支持

S5110V2系列

不支持

S5110V2-SI系列

不支持

S5000V3-EI系列

不支持

S5000E-X系列

不支持

E128C

E152C

E500C系列

E500D系列

不支持

MS4520V2系列(除MS4520V2-30F)

不支持

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

不支持

WS5850-WiNet系列

不支持

WS5820-WiNet系列

WS5810-WiNet系列

不支持

WAS6000系列

不支持

 

3.3  配置步骤

1. 配置Puppet master

(1)       配置Puppet master的IP地址(略)。

(2)       用以下命令安装Puppet。

$ sudo apt-get install puppetmaster

(3)       查看基本配置文件puppet.conf是否已在目录/etc/puppet下自动创建。

如果该文件不存在,执行以下命令。

$ sudo puppet master –genconfig > puppet.conf

(4)       添加H3C提供的文件。

a.   在目录/etc/puppet/modules/custom/lib/puppet/下添加H3C提供的type和provider库文件,将该目录下原有的type目录和provider目录下文件覆盖。

b.   用以下命令在目录/etc/puppet/下创建目录manifests/nodes。

$ sudo mkdir –p /etc/puppet/manifests/nodes

c.   在目录/etc/puppet/manifests/nodes/下添加H3C提供的puppet.master.com.pp文件

(5)       配置site.pp文件。

# 到上一层目录/etc/puppet/manifests/下创建Puppet agent信息文件site.pp。

$ cd ..

$ sudo touch site.pp

# 编辑site.pp文件的内容如下:

node '16.1.136.133'{

  netdev_device{'device':

    ensure => undo_shutdown,

    username => 'test',

    password => 'test',

    ipaddr => '16.1.136.133',

    }

    include custom

}

node '16.1.136.134'{

  netdev_device{'device':

    ensure => undo_shutdown,

    username => 'test',

    password => 'test',

    ipaddr => '16.1.136.134',

    }

    include custom

}

(6)       配置init.pp文件。

# 在目录/etc/puppet/下创建保存配置脚本文件的目录modules/custom/manifests。

$ sudo mkdir -p /etc/puppet/modules/custom/manifests

# 在目录/etc/puppet/modules/custom/manifests下创建配置脚本文件init.pp。

$ sudo touch init.pp

# 编辑init.pp文件的内容如下:

class custom{

  netdev_vlan{'vlan100':

    ensure => undo_shutdown,

    id => 100,

    require => Netdev_device['device'],

    }

}

2. 配置Puppet agent(以Device A为例)

(1)       配置设备的IP地址。

<DeviceA> system-view

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ip address 16.1.136.133 255.255.0.0

[DeviceA-Vlan-interface2] quit

(2)       配置设备作为NETCONF over SSH服务器。

# 生成默认名称的本地RSA非对称密钥对。

[DeviceA] public-key local create rsa

# 开启NETCONF over SSH服务器功能。

[DeviceA] netconf ssh server enable

# 设置NETCONF over SSH客户端登录用户线的认证方式为AAA认证。

[DeviceA] line vty 0 63

[DeviceA-line-vty0-63] authentication-mode scheme

[DeviceA-line-vty0-63] quit

# 创建设备管理类本地用户test,并设置密码为明文test,服务类型为SSH,用户角色为network-admin。

[DeviceA] local-user test class manage

[DeviceA-luser-manage-test] password simple test

[DeviceA-luser-manage-test] service-type ssh

[DeviceA-luser-manage-test] authorization-attribute user-role network-admin

[DeviceA-luser-manage-test] quit

(3)       配置设备作为NTP客户端与Puppet master进行时间同步。

# 开启NTP服务。

[DeviceA] ntp-service enable

# 配置设备通过NTP协议获取时间。

[DeviceA] clock protocol ntp

# 配置设备为NTP广播客户端,从VLAN接口2接收NTP广播报文。

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ntp-service broadcast-client

[DeviceA-Vlan-interface2] quit

(4)       在设备上执行third-part-process start命令启动Puppet。

[DeviceA] third-part-process start name puppet arg agent --certname=16.1.136.133 --server=16.1.147.150

设备启动Puppet后会向Puppet master申请证书。

3. 通过Puppet master给Puppet agent签发证书

# 在Puppet master上可以通过puppet cert list命令查看待签发证书的设备,并通过执行以下命令给Device A签发证书。

$ sudo puppet cert sign 16.1.136.133

Device A获得证书后,将获取Puppet master中的配置脚本到本地运行,实现对设备各功能的配置。

# 通过Puppet master给Device B签发证书(略)。

3.4  验证配置

查看设备配置,可以看到创建了VLAN 100。

3.5  配置文件

·            Puppet master

type、provider和puppet.master.com.pp文件由H3C技术支持提供。

Device A

#

 clock protocol ntp

#

interface Vlan-interface2

 ip address 16.1.136.133 255.255.0.0

 ntp-service broadcast-client

#

 ntp-service enable

#

line vty 0 63

 authentication-mode scheme

 user-role network-admin

 user-role network-operator

 idle-timeout 0 0

#

local-user test class manage

 password hash $h$6$x0kIJnaHZkFFa3Ga$H4yMQnG96xjHiTID+6UPyJrTLXru6RJaGqrCKpxmo2O

KUVWujeoTcDEovLt6LzKIUyN7J3i5Tq2rOQPdj2Nrww==

 service-type ssh

 authorization-attribute user-role network-admin

 authorization-attribute user-role network-operator

#

 netconf ssh server enable

#

 

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们