Saturday 23 April 2016

getting started puppet modules.

getting started puppet modules.


Modules are self-contained bundles of code(each individual is manifest) and data.
REF : puppet
Nearly all Puppet manifests belong in modules.
deafault module directory : /etc/puppet/modules

1)puppet help module.
cmd : puppet help module

def : This subcommand can find, install, and manage modules from the Puppet Forge,
a repository of user-contributed Puppet code. It can also generate empty
modules, and prepare locally developed modules for release on the Forge.

USAGE: puppet module <action> [--environment production ]
[--modulepath $basemodulepath ]

2) module action.
ACTIONS:
  build        Build a module release package.
  changes      Show modified files of an installed module.
  generate     Generate boilerplate for a new module.
  install      Install a module from the Puppet Forge or a release archive.
  list         List installed modules
  search       Search the Puppet Forge for a module.
  uninstall    Uninstall a puppet module.
  upgrade      Upgrade a puppet module.

3) puppet module directory
module directory : /etc/puppet/modules

4) createing the boilerplate for your module
cmd : sudo puppet module generate my-voice
The below will render the metadata of the module my-voice
result :
{
  "name": "my-voice",
  "version": "0.1.0",
  "author": "my",
  "summary": null,
  "license": "Apache 2.0",
  "source": "",
  "project_page": null,
  "issues_url": null,
  "dependencies": [
    {"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
  ]
}


5) list the puppet module.

cmd : sudo puppet module list

Warning: Missing dependency 'puppetlabs-stdlib':
  'my-voice' (v0.1.0) requires 'puppetlabs-stdlib' (>= 1.0.0)
/etc/puppet/modules
├── accounts (???)
└── my-voice (v0.1.0)

6) Install the module from the puppetlab
"puppetlabs-stdlib"
cmd : sudo puppet module install puppetlabs-stdlib
output :
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└── puppetlabs-stdlib (v4.11.0)

7) search puppet module in puppetlabs.
output :
Notice: Searching https://forgeapi.puppetlabs.com ...
NAME                   DESCRIPTION                                                                             AUTHOR        KEYWORDS
sharumpe-apache2       Module to manage Apache2 v2.4 in OpenSuSE 13.1                                          @sharumpe
puppetlabs-apache      Installs, configures, and manages Apache virtual hosts, web services, and modules.      @puppetlabs   web httpd rhel apache2 ssl wsgi proxy
nodes-php              Puppet module to manage PHP, PECL & PEAR on debian / ubuntu - easily expandable to ...  @nodes        php pecl pear apc curl gd ssh2 apache2 fpm
saz-php                UNKNOWN                                                                                 @saz          apache debian ubuntu php apache2 fpm cli
mstanislav-apache_yum  UNKNOWN

8) install puppetlabs-apache.
sudo puppet module install puppetlabs-apache

a) sudo puppet module install puppetlabs-apt
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-apt (v2.2.2)
  └── puppetlabs-stdlib (v4.11.0)


9) puppet module upgrade.
cmd : sudo puppet module upgrade puppetlabs-apt

Could not generate directory puppet

Error: Could not generate directory "voice", you must specify a dash-separated username and module name.
Error: Try 'puppet help module generate' for usage.

cmd : sudo puppet module generate voice

solution :  sudo puppet module generate my-voice

getting started puppet manifest

getting started puppet manifest

1) check the default resources list for puppet.

cmd :
puppet resource [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] [-p|--param parameter] [-t|--types] [-y|--to_yaml] type [name] [attribute=value ...]

REF : puppet

command : puppet resources --types

output :

augeas,computer,cron,exec,file,filebucket,group,host,interface,k5login,macauthorization,mailalias,maillist,mcx,mount,nagios_command
nagios_contact,nagios_contactgroup,nagios_host,nagios_hostdependency,nagios_hostescalation,nagios_hostextinfo,nagios_hostgroup,
nagios_service,nagios_servicedependency,nagios_serviceescalation,nagios_serviceextinfo,nagios_servicegroup,nagios_timeperiod
notify,package,resources,router,schedule,scheduled_task,selboolean,selmodule,service,ssh_authorized_key,sshkey,stage,tidy,user
vlan,whit,yumrepo,zfs,zone,zpool.

2) here in puppet, program are called as manifest.
ex : root.pp.

3) class can be defined as the resuseable component, can be called/used from any where.

def :

class classname {

puppet code

}

Friday 22 April 2016

start puppet and check states of users


1)  start the puppet master.

cmd : systemctl start puppet

check process running on linux.
cmd : top (http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/)

How to check processor and cpu details on Linux
cmd : lscpu
----------------------'
1) puppet will tell state of user.
cmd : puppet resource user root.

output :

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/bash',
  uid              => '12',
}
2) change state of shell command from bash to sh.
a) create a mnifest of the root user.

cmd : sudo puppet resource user root > root.pp

b) save and open the manifest file.

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/sh',
  uid              => '12',
}

c) apply the manifest

puppet apply root.pp

d) now check state of the user again.

cmd : puppet resource user root.

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/sh',
  uid              => '12',
}


3) now if we want to just simulate and dont want to change the state.

cmd :

a) vim root.pp

user { 'root':
  .
  .
  shell            => '/bin/bash',
  .
}
b) puppet apply root.pp  --noop (it show what all the changes might happen to the state if we use it)

REF  :
1) note there is not much of difference in bash/sh
2) puppet


puppet Resource Types reference

puppet resource [options]

--help

'--genconfig'.

* --debug:
  Enable full debugging.

* --edit:
  Write the results of the query to a file, open the file in an editor,
  and read the file back in as an executable Puppet manifest.

* --host:
  When specified, connect to the resource server on the named host
  and retrieve the list of resouces of the type specified.

* --help:
  Print this help message.

* --param:
  Add more parameters to be outputted from queries.

* --types:
  List all available types.

* --verbose:
  Print extra information.


EXAMPLE
-------
This example uses `puppet resource` to return a Puppet configuration for
the user `root`:

    $ puppet resource user root
    user { 'root':
     home => '/home/root',
     uid => '100',
     ensure => 'present',
     comment => 'root comments',
     gid => '1000',
     shell => '/bin/bash',
     groups => ['sysadmin','audio','video','puppet']
    }

Thursday 21 April 2016

find puppet intalled in rhel linux

how to find the version  of puppet intalled in rhel linux

cmd : rpm -qa | grep puppet

puppetlabs-release-7-12.noarch
puppet-...x.noarch
puppet-server-x.x.x.x.noarch

know the linux version

how to know the linux version.
for kernel level.
1) uname -a
2) to know the redhat version then use.
cmd : cat /etc/redhat-release.

puppet Stages for Configuration Management

puppet has Two Stages for Configuration Management
Puppet configures systems in two main stages:

Compile a catalog
Apply the catalog
What is a Catalog?
A catalog is a document that describes the desired system state for one specific computer. It lists all of the resources that need to be managed, as well as any dependencies between those resources.

To compile a catalog, Puppet uses several sources of information. For more info, see the pages on

1) basics of the Puppet language
2) catalog compilation

puppet labs

puppeet lab :

ref: puppet 

try the emulator for getting basic.

1) If we want to see resources available on root user of linux machine.
cmd : puppet resource <user> <name of the user>
ex :  puppet resource user root

output :

st $: puppet resource user root

user { 'root':
 ensure          => 'present',
 comment         => 'root',
 home            => '/root',
 password        => '$1$v4K9E8Wj$gZIHJ5JtQL5ZGZXeqSSsd0',
}

Puppet is describing the current state of the root user in DSL(domain specific language).

The first line is telling us the resource type,in this case user, that the title of this user resource is root.
Then Puppet is displaying a list of attributes that describe the configuration of the root user.

puppet Cheat Sheets and Glossary

puppet Cheat Sheets and Glossary

REF :

1)  Core Types Cheat Sheet
2) Module Cheat Sheet
3) Glossary

puppet for manage the configuration

what is puppet.
Puppet is designed to manage the configuration of Unix-like and Microsoft Windows systems decoratively.
The user describes system resources and their state.
ref : wikipedia 
puppet is not a scripting language.
since we are changing the state of a resource.


step tp set up slave machines on jenkins


set up  slave machines on jenkins

solution :

1) go to jemkins homepage.
2) go to manage jenkins
3) see the messages
"Slave to master security subsystem is currently off. Please read the documentation and consider turning it on."
click on examine.
or
4) go to "Configure Global Security" at bottom of page "plugin manager"
click on enable slave.


add the modes in jenkins.

ref: jenkins
node name :
mySlave

1) go to jemkins homepage.
2) go to manage jenkins
3) add new node
4) define the name,
  # of executors,
Remote root directory(local folder where jenkins to resider),
5) and save.
6) go to jenkins homepage,newly created node and and click on local box

error : RequestAbortedException: java.io.IOException: Unexpected termination of the channel

Wednesday 20 April 2016

Cannot allocate memory/insufficient memory for the Java Runtime Environment to continue.

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000f71a2000, 16084992, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 16084992 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /var/lib/jenkins/jobs/subcontract/workspace/hs_err_pid10731.log

ERROR: Maven JVM terminated unexpectedly with exit code 1
Finished: FAILURE

solution :

increase the java memory maximum heap and initial heap

You can do this to the JAVA_OPTS variable in the bin/catalina.sh startup script.

JAVA_OPTS="-Xms128m -Xmx256m"

jenkins,github Failed to connect to repository

Failed to connect to repository : Command "/usr/bin/git -c core.askpass=true ls-remote -h
...
stderr: remote: Invalid username or password

problem : jenkins is trying to handshake with git with the provided credentials. but unable to login.

solution :
1) Go to jenkins homepage.

2) Go to credentials, add git user name and password.

3) Go to jenkins project, select new added credentials from the dropdown.





Tuesday 19 April 2016

No database selected

ERROR 1046 (3D000): No database selected

we have two scenario
1) check if database exist.
2) if database not exist, create and use the database.

for case 1.

1) see database.
cmd :  show databases.
it will show default listing.
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec

now we have to create the DB and recheck again.

2)  if database not exist, create and use the database.
a) create database test.
cmd : create database test.
b) check test db created or not.
cmd : show databases.

+--------------------+
| Database           |
+--------------------+
| information_schema |
  test
+--------------------+
1 row in set (0.00 sec

c) start using the database.
cmd : use test.



  

ping not recognised in window 7

ping not recognised in window 7

It happen because system is unable to find path of system32 directory.

To resolve this.

go to directory
ex : C:\Windows\System32

search for ping.exe and set the path.

Go to computer -> right click-> properties->system->Advance system setting->Environmental variable
In the system variable -> PATH->
include : C:\Windows\System32
and save.

open command prompt and type ping.

 result :

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
            [-r count] [-s count] [[-j host-list] | [-k host-list]]
            [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name
...

mysql admin URL and port

Mysql admin URL

1) log in to mysql  from your box.
cmd : mysql.
2) To see the URL
cmd : mysql > select user();
result : root@localhost
3) Mysql port number.
cmd :
a) SHOW VARIABLES.
b) SHOW VARIABLES WHERE Variable_name = 'port';

Note :
a) default username : root
b) default password : ""(no password)
c) default port is 3306

Monday 18 April 2016

ClassNotFoundException: .. ContextLoaderListener

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

  1. Open the project's properties (e.g., right-click on the project's name in the project explorer and select "Properties").
  2. Select "Deployment Assembly".
  3. Click the "Add..." button on the right margin.
  4. Select "Java Build Path Entries" from the menu of Directive Type and click "Next".
  5. Select "Maven Dependencies" from the Java Build Path Entries menu and click "Finish".

remove directory in linux

Remove directory in linux.

delete directory
cmd :  rm -r mydir

delete directory and files with in directory

cmd :  rm -r mydir


REF : computerhope

jenkins tomcat 401 Unauthorized

jenkins tomcat 401 Unauthorized

org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username and password you provided are not correct (error 401)


tomcat 401 Unauthorized

You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.

org.codehaus.cargo.container.ContainerException: Failed to redeploy [/var/lib/jenkins/jobs/../..SNAPSHOT.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:189)

solution : goto tomcat "conf " directory and open tomcat-user.xml.

check two things.

1) uncomment below code

<tomcat-users>
<role rolename="manager-gui"/>
<user name="tomcat" password="s3cret" roles="standard,manager-gui"/>
</tomcat-users>

2) or add "standard" in the roles.

Sunday 17 April 2016

AWS jenkins tomcat "ConnectException: Connection timed out"


AWS jenkins tomcat "ConnectException: Connection timed out"

Error 1.
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy
Caused by: java.net.ConnectException: Connection timed out

error 2.
This site can’t be reached
xx.xxx.xx.xxx took too long to respond.
ERR_CONNECTION_TIMED_OUT

solution :

go to network and setting --> click on "deafault" name
edit indound rule.
add "cunstom tcp rule" add the custom port that you want to listen ex:8090 or 3000
save.

open a port in linux using firefall-cmd

open a port in linux using firefall-cmd.

before running the command install firewalld package.

1) install the firewalld on linux
cmd : yum install firewalld
2) check status.
cmd : systemctl status firewalld
if it is not enable, enable it.
cmd : systemctl enable firewalld
3) if it not started start it.
cmd : systemctl start firewalld

4) stop the firewall
cmd : service firewalld stop



Now we have to open the port which will visible to public
open port :
cmd : firewall-cmd --zone=public --add-port=8090/tcp --permanent

reload the service :
firewall-cmd --reload

check whether the port was added to ipatables rules:
iptables-save | grep 8090

REF :
1) liquidweb
2) linuxconfig

Maven fails to parse POMs jenkins

Maven Failed to parse POMs jenkins
hudson.maven.MavenEmbedderException: 1 problem was encountered while building the effective settings
[FATAL] Non-readable settings /usr/../apache-maven/apache-maven-3.2.1/conf: /usr/../apache-maven/apache-maven-3.2.1/conf (Is a directory) @ /usr/../apache-maven/apache-maven-3.2.1/conf

Solution :

Go to jenkins homepage.

Go the project/job which was deployed.

Go to configuration -> build - > advance-

From the setting file dropdown -- > choose default maven setting option and save.

And build the jenkins job.