launch centos7 vm from vagrant
Assume you use msys/cygwin shell on win or shell on OSX, we download centos7 Vagrant template and customized to vm for one single vm node openstack test.
- vm hostname: ctopenstack
- vm cpu: 2
- vm memory: 6GB
- 1 NIC: NAT
- 2 NIC: hostonly 10.120.0.21
mkdir -p vagrant/ctopenstack cd vagrant/ctopenstack curl -LO https://raw.githubusercontent.com/robertluwang/cloud-hands-on-guide/master/dc-vagrant-cloud/ctopenstack/Vagrantfile
here is Vagrantfile for our test,
Vagrant.configure("2") do |config| config.vm.box="dreamcloud/centos7" config.ssh.insert_key = false config.vm.box_check_update = false config.vm.define "ctopenstack" do |ct7| ct7.vm.hostname = "ctopenstack" ct7.vm.network :private_network, ip: "10.120.0.21" ct7.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"] vb.name="ctopenstack" vb.memory=6144 vb.cpus=2 end end end
then start it up
vagrant up vagrant ssh
There are 2 NIC up now, enp0s3 for NAT, internet access, enp0s8 hostonly for private network, used for openstack later.
2: enp0s3:mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:1a:ee:83 brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3 valid_lft 80985sec preferred_lft 80985sec inet6 fe80::a00:27ff:fe1a:ee83/64 scope link valid_lft forever preferred_lft forever 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:42:be:e2 brd ff:ff:ff:ff:ff:ff inet 10.120.0.21/24 brd 10.120.0.255 scope global enp0s8 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe42:bee2/64 scope link valid_lft forever preferred_lft forever
verify internet access
[vagrant@ctopenstack ~]$ ping -c 4 google.ca PING google.ca (172.217.12.67) 56(84) bytes of data. 64 bytes from dfw28s05-in-f3.1e100.net (172.217.12.67): icmp_seq=1 ttl=47 time=106 ms 64 bytes from dfw28s05-in-f3.1e100.net (172.217.12.67): icmp_seq=2 ttl=47 time=47.1 ms 64 bytes from dfw28s05-in-f3.1e100.net (172.217.12.67): icmp_seq=3 ttl=47 time=47.1 ms 64 bytes from dfw28s05-in-f3.1e100.net (172.217.12.67): icmp_seq=4 ttl=47 time=47.4 ms
shared host folder mounted,
df -h|grep vagrant vagrant 440G 259G 182G 59% /vagrant
sudo is ready,
[vagrant@ctopenstack ~]$ sudo pwd /home/vagrant
install openstack using packstack
This is official doc for packstack deploy.
step 0 prestep
[vagrant@ctopenstack ~]$ sudo systemctl disable firewalld [vagrant@ctopenstack ~]$ sudo systemctl stop firewalld [vagrant@ctopenstack ~]$ sudo systemctl disable NetworkManager Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service. [vagrant@ctopenstack ~]$ sudo systemctl stop NetworkManager [vagrant@ctopenstack ~]$ sudo systemctl enable network network.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig network on [vagrant@ctopenstack ~]$ sudo systemctl start network
step 1 Software repositories
$ sudo yum install -y centos-release-openstack-pike $ yum-config-manager --enable openstack-pike $ sudo yum update -y
step 2 Install Packstack Installer
$ sudo yum install -y openstack-packstack
Step 3 Run Packstack to install OpenStack
before run packstack, we need to give correct private network ip for openstack, by default packstack will take first NIC which is NAT ip for my case, but I prefer 2nd NIC hostonly ip as openstack admin ip, to allow local host access to it for example dashboard GUI.
first of all need to generate config file by,
sudo packstack --gen-answer-file=packstack_date +"%Y-%m-%d"
.conf
we replaced NIC ip with hostonly ip manually,
[vagrant@ctopenstack ~]$ cat packstack_2018-01-20.conf |grep 10.0.2.15 CONFIG_CONTROLLER_HOST=10.0.2.15 CONFIG_COMPUTE_HOSTS=10.0.2.15 CONFIG_NETWORK_HOSTS=10.0.2.15 CONFIG_STORAGE_HOST=10.0.2.15 CONFIG_SAHARA_HOST=10.0.2.15 CONFIG_AMQP_HOST=10.0.2.15 CONFIG_MARIADB_HOST=10.0.2.15 CONFIG_KEYSTONE_LDAP_URL=ldap://10.0.2.15 CONFIG_REDIS_HOST=10.0.2.15 [vagrant@ctopenstack ~]$ sed -i 's/10.0.2.15/10.120.0.21/g' packstack_2018-01-20.conf [vagrant@ctopenstack ~]$ cat packstack_2018-01-20.conf |grep 10.0.2.15 [vagrant@ctopenstack ~]$ cat packstack_2018-01-20.conf |grep 10.120.0.21 CONFIG_CONTROLLER_HOST=10.120.0.21 CONFIG_COMPUTE_HOSTS=10.120.0.21 CONFIG_NETWORK_HOSTS=10.120.0.21 CONFIG_STORAGE_HOST=10.120.0.21 CONFIG_SAHARA_HOST=10.120.0.21 CONFIG_AMQP_HOST=10.120.0.21 CONFIG_MARIADB_HOST=10.120.0.21 CONFIG_KEYSTONE_LDAP_URL=ldap://10.120.0.21 CONFIG_REDIS_HOST=10.120.0.21
now we can start to run packstack with own config file, it took around one hour to finish,
[vagrant@ctopenstack ~]$ sudo packstack --answer-file packstack_2018-01-20.conf Welcome to the Packstack setup utility The installation log file is available at: /var/tmp/packstack/20180120-223943-9e5pVY/openstack-setup.log Installing: Clean Up [ DONE ] Discovering ip protocol version [ DONE ] Setting up ssh keys [ DONE ] Preparing servers [ DONE ] Pre installing Puppet and discovering hosts' details [ DONE ] Preparing pre-install entries [ DONE ] Setting up CACERT [ DONE ] Preparing AMQP entries [ DONE ] Preparing MariaDB entries [ DONE ] Fixing Keystone LDAP config parameters to be undef if empty[ DONE ] Preparing Keystone entries [ DONE ] Preparing Glance entries [ DONE ] Checking if the Cinder server has a cinder-volumes vg[ DONE ] Preparing Cinder entries [ DONE ] Preparing Nova API entries [ DONE ] Creating ssh keys for Nova migration [ DONE ] Gathering ssh host keys for Nova migration [ DONE ] Preparing Nova Compute entries [ DONE ] Preparing Nova Scheduler entries [ DONE ] Preparing Nova VNC Proxy entries [ DONE ] Preparing OpenStack Network-related Nova entries [ DONE ] Preparing Nova Common entries [ DONE ] Preparing Neutron LBaaS Agent entries [ DONE ] Preparing Neutron API entries [ DONE ] Preparing Neutron L3 entries [ DONE ] Preparing Neutron L2 Agent entries [ DONE ] Preparing Neutron DHCP Agent entries [ DONE ] Preparing Neutron Metering Agent entries [ DONE ] Checking if NetworkManager is enabled and running [ DONE ] Preparing OpenStack Client entries [ DONE ] Preparing Horizon entries [ DONE ] Preparing Swift builder entries [ DONE ] Preparing Swift proxy entries [ DONE ] Preparing Swift storage entries [ DONE ] Preparing Gnocchi entries [ DONE ] Preparing Redis entries [ DONE ] Preparing Ceilometer entries [ DONE ] Preparing Aodh entries [ DONE ] Preparing Puppet manifests [ DONE ] Copying Puppet modules and manifests [ DONE ] Applying 10.120.0.21_controller.pp 10.120.0.21_controller.pp: [ DONE ] Applying 10.120.0.21_network.pp 10.120.0.21_network.pp: [ DONE ] Applying 10.120.0.21_compute.pp 10.120.0.21_compute.pp: [ DONE ] Applying Puppet manifests [ DONE ] Finalizing [ DONE ] **** Installation completed successfully ****** Additional information: * Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components. * File /root/keystonerc_admin has been created on OpenStack client host 10.120.0.21. To use the command line tools you need to source the file. * To access the OpenStack Dashboard browse to http://10.120.0.21/dashboard . Please, find your login credentials stored in the keystonerc_admin in your home directory. * The installation log file is available at: /var/tmp/packstack/20180120-223943-9e5pVY/openstack-setup.log * The generated manifests are available at: /var/tmp/packstack/20180120-223943-9e5pVY/manifests
you can open another ssh session to monitor the packstack installation progress during installation,
tail -f /var/tmp/packstack/latest/openstack-setup.log
launch openstack dashboard GUI
You can get admin password from keystonerc_admin,
[vagrant@ctopenstack ~]$ sudo cat /root/keystonerc_admin unset OS_SERVICE_TOKEN export OS_USERNAME=admin export OS_PASSWORD='2992c7dd428e4f4e' export OS_AUTH_URL=http://10.120.0.21:5000/v3 export PS1='[\u@\h \W(keystone_admin)]\$ ' export OS_PROJECT_NAME=admin export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3
verify dashboard url,
[vagrant@ctopenstack ~]$ curl http://10.120.0.21:5000/v3 {"version": {"status": "stable", "updated": "2017-02-22T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.8", "links": [{"href": "http://10.120.0.21:5000/v3/", "rel": "self"}]}}[vagrant@ctopenstack ~]$
from local browser, type in http://10.120.0.21/dashboard.
Until now the one single node centos7 openstack ready to go!
lazy setup one vm node openstack using vagrant
If you feel boring to run above setup and script, I provide a ready to go Vagrantfile, you can launch a one node openstack box automatically.
mkdir -p vagrant/ctopenstack cd vagrant/ctopenstack curl -Lo Vagrantfile https://raw.githubusercontent.com/robertluwang/cloud-hands-on-guide/master/dc-vagrant-cloud/ctopenstack/Vagrantfile.pack
then openstack box ready for you!
If you like it, don’t mind to give a star :)