Custom Search
Showing posts with label Puppet. Show all posts
Showing posts with label Puppet. Show all posts

Monday, October 12, 2015

puppet how to manually run a class

1)
how to manually run a class
------------------------------

$echo 'include rjil::system::apt' | puppet apply
$echo 'include rjil::system::apt' | puppet apply --debug
$echo 'include rjil::system::apt' | puppet apply --debug ---noop

2)
How to add entry in /etc/hosts
---------------------------------------

$echo "include rjil::jiocloud::dns" | puppet apply

notify {"ip=${ip}, cname=${cname}, name=${name}":}  === print
notify {"ip=${ip}, ip_real=${ip_real}":}

Notice: ip=false, cname=keystone.service.consul, name=identity.jiocloud.com
Notice: ip=false, ip_real=10.140.15.69

/etc/puppet/modules.overrides/rjil/manifests/jiocloud/dns/entry.pp

3)
How consul check keystone service
-------------------------------------------------------
a)
$vim puppet-rjil/manifests/keystone.pp

  rjil::jiocloud::consul::service { "keystone":
    tags          => ['real'],
    port          => 5000,
  }

b)
$vim puppet-rjil/manifests/jiocloud/consul/service.pp

  file { "/etc/consul/$name.json":
    ensure => "present",
    content => template('rjil/consul.service.erb'),
  } ~> Exec <| title == 'reload-consul' |>

c)
vim /etc/consul/keystone.json

{
  "service": {
    "name": "keystone",
    "port": 5000,
    "tags": [
      "real"
    ],
    "check": {
      "script": "/usr/lib/jiocloud/tests/service_checks/keystone.sh",
      "interval": "10s"
    }
  }
}

* Consul will read this json file and execute the script in the "check" section, then register the service if check is success.

d)
$vim /usr/lib/jiocloud/tests/service_checks/keystone.sh

#!/bin/bash
set -e
/usr/lib/nagios/plugins/check_http -S -H 10.140.15.66 -p 5000

4)









Wednesday, June 3, 2015

How to test puppet code : Test Spec error and Compilation error

1)
#sudo apt-get install ruby
#sudo apt-get install ruby-dev


2)
http://bundler.io/
#sudo gem install bundler

3)
Clone puppet project from github and goto cloned folder and run.


#bundle install
OR
#bundle install --gemfile=Gemfile


* This will install all the dependencies defined in the "Gemfile"
* Use `bundle show [gemname]` to see where a bundled gem is installed.
* https://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing

4)
Run spec tests in a clean fixtures directory

#rake spec
OR
#bundle exec rake spec

* Run "#rake" to get help page

5)
Check that your Puppet manifest conform to the style guide
#bundle exec rake lint
#bundle exec rake lint | grep ERROR

6)
To check for compilation errors and view a log of events.
#puppet apply --noop --debug manifests/init.pp



Thursday, May 21, 2015

puppet ruby rspec: gsub example



1)
#vim  exampl2.erb

##9 spaces i given. gsub removes first 8 spaces from lines which start with space.

print "         HelloSaju".gsub(/^ {8}/, '')

print "\n"



2)
#vim example1.erb

print <<-api b="">.gsub(/^ {8}/, '')
        [DEFAULTS]
        ifmap_server_ip=10.1.1.1
        ifmap_server_port=8443
        ifmap_username=api-server
        ifmap_password=api-server

        [SECURITY]
        use_certs=false
        keyfile=/etc/contrail/ssl/private_keys/apiserver_key.pem
        certfile=/etc/contrail/ssl/certs/apiserver.pem
        ca_certs=/etc/contrail/ssl/certs/ca.pem

        [KEYSTONE]
        auth_host=10.1.1.2
        auth_protocol=http
        auth_port=35357
        admin_user=admin
        admin_password=admin_password
        admin_token=admin_token
        admin_tenant_name=openstack
      API


print "\n"





Friday, July 4, 2014

How to OpenStack Puppet Submit Blueprint Patch Set

http://docs.openstack.org/training-guides/content/operator-getting-started-lab.html

https://wiki.openstack.org/wiki/Gerrit_Workflow

1)
* Install git and pip

#sudo apt-get install git
#sudo apt-get install python-pip


2)
* Install git-review

#sudo pip install git-review

3)
* Configure github


#git config -l

#git config --global user.name "Saju Madhavan"
#git config --global user.email "sajuptpm@gmail.com"
#git config --global core.editor "vim"

#git config -l


4)
Clone the "puppet-heat" project
#git clone https://github.com/stackforge/puppet-heat.git

5)
#cd puppet-heat

6)
* Test the ssh key setup
* If this not working, complete the step-7 and try this step again.

#git review -s
Enter your gerrit username: sajuptpm

7)
* Optional, if you are trying to submit the code from different machine

* I you already registered your SSH keys to github and Launchpad, copy your "id_rsa" and "id_rsa.pub" to ~/ssh folder of new machine.
#cd ~/.ssh
#scp id_rsa saju@192.168.56.102:~/.ssh
#scp id_rsa.pb saju@192.168.56.102:~/.ssh


8)
My blueprint

https://blueprints.launchpad.net/puppet-heat/+spec/option-to-configure-falvor-in-heat.conf

9)
Create a new branch for our blueprint changes

#cd puppet-heat
#git checkout -b blueprint/option-to-configure-falvor-in-heat.conf


10)
Check the branch

#git branch

11)
make your changes


12)
Commit your changes
#git add file1 file2
#git commit -a


commit messageee
Implements: blueprint option-to-configure-falvor-in-heat.conf


13)

Push changes to https://review.openstack.org
#git review

14)
https://review.openstack.org/104795
https://review.openstack.org/#/c/104795/

15)
Resubmit same patch after some modification

#git commit -a --amend

Thursday, July 3, 2014

OpenStack Heat Puppet Error: Could not find dependency Exec[heat-dbsync] for Service[heat-engine] at /var/puppet/modules/heat/manifests/engine.pp:72


Fix
====

Specify the attribute "sql_connection" of class { '::heat':

sql_connection => "sqlite:////var/lib/heat/sqlite_db",









Wednesday, July 2, 2014

Install OpenStack Horizon Using Puppet

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-horizon"
https://github.com/stackforge/puppet-horizon/blob/master/README.md

* Run "puppet man module" to get help

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

b)
* Install unstable "puppet-horizon"
https://github.com/stackforge/puppet-openstack#installing-latest-unstable-openstack-module-from-source

# cd /var/puppet/modules
# git clone https://github.com/stackforge/puppet-horizon.git horizon
# cd horizon
# 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 { '::horizon':
    secret_key => "secretkkkkk",
    keystone_url => "http://192.168.56.1:5000/v2.0",
    package_ensure => "latest",
  }

https://github.com/stackforge/puppet-horizon/blob/master/manifests/init.pp

6)
a)
* Check "README.md" of "puppet-horizon" module
https://github.com/stackforge/puppet-horizon/blob/master/README.md

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

8)
Run puppet and install Horizon
# sudo puppet apply  --verbose --modulepath /var/puppet/modules site.pp

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

9)
Access Horizon Dashboard
http://hostname_of_machine_where_you_installed_horizon

10)
Added following line in "/etc/hosts" if you want to access from different machine
#vim /etc/hosts
ip_of_machine_where_you_installed_horizon hostname_of_machine_where_you_installed_horizon

11)
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

12)
OpenStackPuppetHowto
https://wiki.debian.org/OpenStackPuppetHowto



Monday, June 30, 2014

Howto Install Configure and Run Latest Puppet in Ubuntu


http://www.ubuntuupdates.org/ppa/puppet_repo

a)
Setup the key with:
https://apt.puppetlabs.com/
$ wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
$ sudo dpkg -i
puppetlabs-release-trusty.deb



b)
Setup repository with:
#sudo sh -c 'echo "deb http://apt.puppetlabs.com// trusty main" >> /etc/apt/sources.list.d/puppet.list'

c)
#sudo apt-get update

d)
#sudo apt-get install puppet


Monday, June 23, 2014

Qemu KVM How To Open VM console










Puppet KVM internal error Process exited while reading console log output: char device redirected to /dev/pts/0 Could not access KVM kernel module: No such file or directory

 
Error
======= 
2014-06-23 11:40:29.020+0000: 1117: error : qemuProcessReadLogOutput:1062 : internal error Process exited while reading console log output: char device redirected to /dev/pts/0
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
No accelerator found!
 
Fix
=====