gdrocket 发表于 2017-6-27 14:11:13

2. 自动化运维系列之Cobbler给Openstack节点安装操作系统。

preface
  我们在一篇博文知道了如何搭建Cobbler,那么下面就通过Cobbler来安抓Openstack所有节点吧。
  服务器配置信息如下:

主机名
IP
角色
Cobbler.node.com
192.168.56.10
cobbler
linux-node1.example.com
192.168.56.11
keystone+glance等控制节点
linux-node2.example.com
192.168.56.12
horizon+nova-computer等计算节点

[*]内核为3.10.0-514.2.2.el7.x86_64
[*]网卡名字设置为了eth0。
[*]关闭了selinux,iptables。
[*]时间同步ntp.chinacache.com
部署cobbler
  部署的话参考上一篇博文:Cobbler的安装
  
1.Cobbler安装部署完成后,我们需要添加 一个 Openstack仓库:
  

# cobbler repo add --name=Openstack-Newton --mirror=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-newton/ --arch=x86_64 --breed=yum  
# cobbler reposync   # 同步得有一会,取决于下载速度。
  

  同步完成后,我们在Cobbler-web界面来把Openstack的源添加到profile里面去,这样新安装的操作系统自动Openstack-newton版本的yum源了。如下图所示:
  

  
2.kickstart配置文件里面添加一行命令:
  

# vim CentOS-7.1-x86_64_cobbler.cfg  

  
%post
  
rpm -ihv https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm    # 添加一个epel源
  
wget -SO/etc/yum.repos.d/Centos-7.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  
yum clean all && yum -y install koan   # 安装koan
  
%end
  

  3.定制系统:
  
首先针对linux-node2节点:
  

#cobbler system add --name=linux-node2 --mac=00:50:56:3E:61:CF \  
--profile=CentOS-7.0-x86_64 \
  
--ip-address=192.168.56.12 --subnet=255.255.255.0 \
  
--gateway=192.168.56.2 --interface=eth0 \
  
--static=1 --hostname=linux-node2.example.com \
  
--name-servers="192.168.56.2" \
  
--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64_cobbler.cfg
  

  再次针对linux-node1节点
  

cobbler system add --name=linux-node1 --mac=00:50:56:25:62:A4 \  
--profile=CentOS-7.0-x86_64 \
  
--ip-address=192.168.56.11 --subnet=255.255.255.0 \
  
--gateway=192.168.56.2 --interface=eth0 \
  
--static=1 --hostname=linux-node1.example.com \
  
--name-servers="192.168.56.2" \
  
--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64_cobbler.cfg
  

  如果是使用的vm虚拟机,请先关闭vmware虚拟机的DHCP功能,如果是在生产环境下,那么请临时关闭路由器或者三层交换机的dhcp功能,由Cobbler来提供dhcp功能。

启动Openstack节点服务器
  我们启动Openstack节点服务器,一开机就进入到自动安装系统的界面。待系统安装完后,我们就可以看到主机名、ip、网关、防火墙之类的都是按照我们的配置文件走的。
  
我们看下yum源:
  

# cat /etc/yum.repos.d/cobbler-config.repo  

  
# error: could not read repo source: /var/www/cobbler/ks_mirror/config/CentOS-7.0-x86_64-0.repo
  

  

  
name=Openstack-Newton
  
baseurl=http://192.168.56.10/cobbler/repo_mirror/Openstack-Newton
  
enabled=1
  
priority=99
  
gpgcheck=0
  

  已经安装上了Newton版本的Openstack的yum源了,所以我们在部署Openstack的节点的时候不需要执行yum -y install centos-release-openstack-newton。
  
直接执行yum install Openstack组件就可以了。
  
由于是使用Cobbler的yum源,所以安装Openstack的组件的时候,内网传输相当快了。
页: [1]
查看完整版本: 2. 自动化运维系列之Cobbler给Openstack节点安装操作系统。