How to change IP address after OpenStack installation via devstack

After you have installed Openstack via devstack, what if you need to change the IP address of OpenStack's controller/compute nodes for whatever reason?

OpenStack deployment via devstack is stateless or ephemeral by design. As such, all OpenStack configuration files and databases are re-generated from scratch every time you run stack.sh. Therefore, when the IP address of any OpenStack node changes, you just need to redefine HOST_IP/SERVICE_HOST environment variables in localrc. All relevant OpenStack configuration files will then automatically be re-generated by stack.sh.

In your OpenStack development environment, if the IP address of an OpenStack node changes often, it is useful to define HOST_IP environment variable in localrc as follows, instead of defining it statically (e.g., 192.168.1.10).

HOST_IP=`ifconfig eth0 | sed -ne 's/.*inet addr:\([^ ]*\).*/\1/p'`

One caveat: there is one more configuration file (besides localrc) that you need to manually update when the IP address of the controller node changes. stack.sh generates a user-specific MySQL configuration file in ~/.my.cnf, and includes the IP address of MySQL server there. If the MySQL configuration file already exists, stack.sh does not overwrite the file. Thus, you need to update the IP address manually, or comment out if-clause in stack.sh, as follows.

#    if [[ ! -e $HOME/.my.cnf ]]; then
         cat <$HOME/.my.cnf
[client]
user=$MYSQL_USER
password=$MYSQL_PASSWORD
host=$MYSQL_HOST
EOF
         chmod 0600 $HOME/.my.cnf
#     fi

Without this change, you may encounter a MySQL connection timeout error on OpenStack controller node while running stack.sh, because it attempts to access MySQL server at an old IP address.


Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

2 thoughts on “How to change IP address after OpenStack installation via devstack

  1. I dont understand the reason for this. If you are going to re ./stack.sh everything, you are basically starting over. Why are you worried about changing IP? This doesn't preserve anything.

    If you can tell us how to do this by ./rejoin-stack.sh that would be better since we could then move our server to a new IP while keeping everything functional, including all our VMs.

  2. Hey Dan.
    The if clause that you have mentioned in comment is not there in my stack.sh file.
    I am using Ubuntu.
    Please help
    Thanx !

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *