Custom Search

Wednesday, July 9, 2014

Howto Install OpenStack Heat standalone Using Puppet

Code: https://github.com/sajuptpm/openstack-puppet-scripts/tree/master/heat_standalone

1)
Install Latest Puppet


# wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
# sudo dpkg -i puppetlabs-release-trusty.deb
# sudo sh -c 'echo "deb http://apt.puppetlabs.com// trusty main" >> /etc/apt/sources.list.d/puppet.list'

# sudo apt-get update

# sudo apt-get install puppet

# puppet --version

# dpkg -L puppet

2)
Create following directories

# sudo mkdir /var/puppet
# sudo mkdir /var/puppet/modules

3)
a)
* Install stable "puppet-heat"

https://github.com/stackforge/puppet-heat/blob/master/README.md
* Run "puppet man module" to get help

# sudo puppet module install --target-dir /var/puppet/modules puppetlabs/heat

b)
* Install unstable "puppet-heat"

https://github.com/stackforge/puppet-openstack#installing-latest-unstable-openstack-module-from-source

# cd /var/puppet/modules
# git clone https://github.com/stackforge/puppet-heat.git heat
# cd heat
# gem install librarian-puppet
# librarian-puppet install --path ../

4)
Create a directory to put your custom puppet files

# mkdir ~/puppet-test
# mkdir ~/puppet-test/manifests
# cd  ~/puppet-test/manifests

5)
Create a "site.pp" to put your puppet code

# cd  ~/puppet-test/manifests
# vim site.pp

class { '::heat':
    keystone_host => "192.168.56.102",
    keystone_port => "35357",
    keystone_user => "heat",
    keystone_tenant => "services",
    package_ensure => "latest",
  }

#https://github.com/stackforge/puppet-heat/blob/master/manifests/init.pp
#http://docs.openstack.org/trunk/config-reference/content/ch_configuring-openstack-orchestration.html

Notes:
* This will not install any heat services like "heat-engine".
* but, this will create the file "/etc/heat/heat.conf" and install "/usr/bin/heat" binary
* To install heat services, we need to invoke other calls, will explain later. see step:12.

6)
a)
* Check "README.md" of "puppet-heat" module

https://github.com/stackforge/puppet-heat/blob/master/README.md

b)
* Check the "init.pp" of "puppet-heat" module and understand the definition of class "heat" and what are the arguments we can pass and what are the default arguments.
https://github.com/stackforge/puppet-heat/blob/master/manifests/init.pp

7)
Run puppet and install heat

# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

You can also use --debug and --noop options


8)
Install "heat-engine".


a)
# cd  ~/puppet-test/manifests
# vim site.pp

class { '::heat':
    keystone_host => "192.168.56.102",
    keystone_port => "35357",
    keystone_user => "heat",
    keystone_tenant => "services",
    package_ensure => "latest",
    sql_connection => "sqlite:////var/lib/heat/sqlite_db",
  }

class { 'heat::engine':
        auth_encryption_key => "mykey123",
}

#https://github.com/stackforge/puppet-heat/blob/master/manifests/engine.pp
#http://docs.openstack.org/trunk/config-reference/content/ch_configuring-openstack-orchestration.html

b)
Run puppet and install heat-engine

# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

You can also use --debug and --noop options

c)
This will create following files


/usr/bin/heat-engine
/usr/bin/heat-keystone-setup
/usr/bin/heat-manage

/etc/init.d/heat-engine

/etc/init/heat-engine.conf

d)
Check following log files to debug


/var/log/heat/heat-engine.log
/var/log/heat/heat-manage.log

e)
Check

#dpkg -L heat-engine

9)
Install "heat-api".


a)
# cd  ~/puppet-test/manifests
# vim site.pp

class { '::heat':
    keystone_host => "192.168.56.1",
    keystone_port => "35357",
    keystone_user => "heat",
    keystone_tenant => "services",
    package_ensure => "latest",
    sql_connection => "sqlite:////var/lib/heat/sqlite_db",
  }

class { 'heat::engine':
        auth_encryption_key => "mykey123",
}

class { 'heat::api':
        bind_host => "127.0.0.1",
        bind_port => "8004",
}


#https://github.com/stackforge/puppet-heat/blob/master/manifests/api.pp
#http://docs.openstack.org/trunk/config-reference/content/orchestration-configuring-api.html

b)
Run puppet and install heat-api

# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

You can also use --debug and --noop options

c)
This will create following files


/usr/bin/heat-api

/etc/init.d/heat-api
/etc/init/heat-api.conf

d)
Check following log files to debug


/var/log/heat/heat-api.log

e)
Check

#dpkg -L heat-api

10)
Install rabbitmq


a)
* Install stable "rabbitmq"

https://github.com/puppetlabs/puppetlabs-rabbitmq/blob/master/README.md
https://forge.puppetlabs.com/puppetlabs/rabbitmq
* Run "puppet man module" to get help

# sudo puppet module install --target-dir /var/puppet/modules puppetlabs/rabbitmq

b)
# cd  ~/puppet-test/manifests
# vim site.pp

####Heat
class { '::heat':
    keystone_host => "192.168.56.1",
    keystone_port => "35357",
    keystone_user => "heat",
    keystone_tenant => "services",
    package_ensure => "latest",
    sql_connection => "sqlite:////var/lib/heat/sqlite_db",
  }


####Heat Engine
class { 'heat::engine':
        auth_encryption_key => "mykey123",
}

####Heat API
class { 'heat::api':
        bind_host => "127.0.0.1",
        bind_port => "8004",
}

####Rabbitmq
class { '::rabbitmq':
}

c)
Run puppet and install rabbitmq

# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

You can also use --debug and --noop options

d)
Check the status of rabbitmq-server

#sudo /etc/init.d/rabbitmq-server status

e)
Ensure that rabbitmq-server is running on port 5672

#sudo netstat -tuplen | grep :5672
#sudo netstat -tuplen | grep :5672 | awk '{ print $9 }'

f)
Ensure that "heat-engine" is working without any issue

#sudo tail -f /var/log/heat/heat-engine.log
#sudo service heat-engine restart

11)
Install "heat-cfn"


a)
What is heat-cfn or heat-cfntools ?


* heat-cfntools are tools required to be installed on Heat provisioned cloud instances (vms).
https://github.com/openstack/heat-cfntools <== IMP

* We an use heat-cfntools to install install packages, and starts services in side a VM with the help of "cfn-init" which Reads the AWS::CloudFormation::Init for the instance resource.

* We can use heat-cfntools to implement WaitCondition in VM with the help of "cfn-signal" which Waits for an application in the VM to be ready before continuing.

b)
# cd  ~/puppet-test/manifests
# vim site.pp

####Heat
class { '::heat':
    keystone_host => "192.168.56.1",
    keystone_port => "35357",
    keystone_user => "heat",
    keystone_tenant => "services",
    package_ensure => "latest",
    sql_connection => "sqlite:////var/lib/heat/sqlite_db",
  }

####Heat Engine
class { 'heat::engine':
        auth_encryption_key => "mykey123",
}

####Heat API
class { 'heat::api':
        bind_host => "127.0.0.1",
        bind_port => "8004",
}

####Rabbitmq
class { '::rabbitmq':
}

####Heat cfn
class { 'heat::api_cfn':
        bind_host => "127.0.0.1",
        bind_port => "8000",
}

#http://docs.openstack.org/trunk/config-reference/content/orchestration-configuring-api.html
#https://github.com/stackforge/puppet-heat/blob/master/manifests/api_cfn.pp

c)
Run puppet and install heat-cfn

# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

You can also use --debug and --noop options

d)
This will create following files


/etc/init.d/heat-api-cfn
/etc/init/heat-api-cfn.conf

/usr/bin/heat-api-cfn

e)
Check following log files to debug

/var/log/heat/heat-api-cfn.log

f)
Check

#dpkg -L heat-api-cfn

12)
How to Setup Standalone Heat

How to get Heat to work with a remote OpenStack

http://docs.openstack.org/developer/heat/getting_started/standalone.html

a)
Edit heat.conf
#sudo vim /etc/heat/heat.conf
flavor=standalone

b)
Restart heat-engine and heat-api

#sudo service heat-engine restart
#sudo service heat-api restart

13)
Confirm that your heat setup is working


* IP of Devstack VM : 192.168.56.102
* IP of Heat Standalone VM : 127.0.0.1


a)
Important Step.

* set accessable endpoints for your main OpenSatck setup. endpoints should be accessable from your heat VM.
http://fosshelp.blogspot.com/2014/07/openstack-devstack-how-to-set-custom.html

b)
b1)

Find the id of the admin tenant. Try to run this command from machine where you installed heat.
* Here --os-auth-url http://192.168.56.102:35357/v2.0 is the endpoint of keystone running in your main OpenStack Setup.
#keystone --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug tenant-list

b2)
Add the id of the admin tenant in --heat-url option and try to execute the command stack-list
* Find id of admin tenant and add in --heat-url , otherwise you will get error "Authentication required"
#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-list

### OR ###(not working now, bug, may be work later after fix)
#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/'%(tenant_id)s' --os-no-client-auth --debug stack-list

b3)
Create stack (working)

* Tail "heat-api.conf" and "heat-engine.conf" and run below command and verify that logs are comming, that means our heat setup is working.
* Find id of admin tenant and add in --heat-url , otherwise you will get error "Authentication required"
* --os-no-client-auth is also required
#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/832be22ed5ef4533a7daa53c895e4606 --os-no-client-auth --debug stack-create mystack1 -f https://raw.githubusercontent.com/openstack/heat-templates/master/hot/hello_world.yaml -P "db_password=123456"


b4)
* Add new KeyName

#nova --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug keypair-add  k1

* List keypairs
#nova --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug keypair-list

* Find imageid
#nova --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug image-list

b5)
Working command (Tested)

#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-create mystack1 -f https://raw.githubusercontent.com/openstack/heat-templates/master/hot/hello_world.yaml -P "db_password=P23456" -P "KeyName=k1" -P "ImageId=13ad8950-1f00-4587-8d3c-dd726265de08"

b6)
List and Check the status of created stack

#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-list

b7)
Find the Ip of the VM created by stack by listing the VMs

#nova --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug list

b8)
Download keypair

#nova --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --debug keypair-show k2

b9)
Delete Stack

#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-delete 8befad68-44ba-4f7d-9a4c-ff68d458decf

b10)
Create stack with our custom template "hello_world.yaml" (Working)

#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-create mystack2 -f hello_world.yaml -P "KeyName=k2" -P "ImageId=13ad8950-1f00-4587-8d3c-dd726265de08"

14)
Important Liks


a)
Note: Read following README.md
https://github.com/puppetlabs/puppetlabs-havana/blob/master/README.md
https://github.com/stackforge/puppet-openstack/blob/master/README.md

b)
Note: Read following docs
* Heat install-guide
http://docs.openstack.org/trunk/install-guide/install/apt/content/ch_heat.html

* Heat config-reference
http://docs.openstack.org/trunk/config-reference/content/ch_configuring-openstack-orchestration.html

c)
Working Repo from IRC guy
https://github.com/sajuptpm/puppet-openstack-cloud/

c1)
Starting Point
https://github.com/sajuptpm/puppet-openstack-cloud/blob/master/manifests/orchestration.pp

c2)
Then, move to
https://github.com/sajuptpm/puppet-openstack-cloud/blob/master/manifests/orchestration/api.pp
https://github.com/sajuptpm/puppet-openstack-cloud/blob/master/manifests/orchestration/engine.pp

d)
Example
https://github.com/stackforge/puppet-heat/blob/master/examples/site.pp


1 comment: