Install ansible on Centos 7 / RHEL 7

Install ansible on Centos 7 / RHEL 7

1. Install epel-release package

yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

2. Installation

2.1 Update the OS
             yum update

2.2 Install the ansible
             yum install ansible

2.3 check ansible version
            ansible –version

 

Puppet – Installing modules

1. Search for puppet modules

1.i from cli
$ puppet module search accounts

1.ii OR from https://forge.puppet.com/

2. Install puppet module from puppet forge repository

$ puppet module install puppetlabs/accounts
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules …
Notice: Downloading from https://forgeapi.puppet.com …
Notice: Installing — do not interrupt …
/etc/puppetlabs/code/environments/production/modules
└─┬ puppetlabs-accounts (v1.3.0)
└── puppetlabs-stdlib (v4.25.1)

3. Install puppet module from different repository

$ puppet module install –module_repository http://dev-forge.example.com puppetlabs-apache

4. Install puppet module from release tar ball

$ puppet module install ~/puppetlabs-apache-0.10.0.tar.gz –ignore-dependencies

5. Show installed puppet modules

$ puppet module list
/etc/puppetlabs/code/environments/production/modules
├── puppetlabs-accounts (v1.3.0)
├── puppetlabs-stdlib (v4.25.1)
├── ssh (???)
└── usermanagement (???)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules
├── puppetlabs-facter_task (v0.3.0)
├── puppetlabs-package (v0.2.0)
├── puppetlabs-pe_accounts (v2016.5.0)
├── puppetlabs-pe_concat (v1.1.1)
├── puppetlabs-pe_hocon (v2016.2.0)
├── puppetlabs-pe_infrastructure (v2018.1.0)
├── puppetlabs-pe_inifile (v1.1.3)
├── puppetlabs-pe_install (v2018.1.0)
├── puppetlabs-pe_java_ks (v2016.4.0)
├── puppetlabs-pe_nginx (v2017.1.0)
├── puppetlabs-pe_postgresql (v2016.5.0)
├── puppetlabs-pe_puppet_authorization (v2016.2.0)
├── puppetlabs-pe_r10k (v2016.2.0)
├── puppetlabs-pe_razor (v0.2.1)
├── puppetlabs-pe_repo (v2018.1.0)
├── puppetlabs-pe_staging (v0.3.3)
├── puppetlabs-pe_support_script (v2.7.0)
├── puppetlabs-puppet_conf (v0.2.0)
├── puppetlabs-puppet_enterprise (v2018.1.0)
└── puppetlabs-service (v0.3.1)

6. Upgrade puppet module

$ puppet module upgrade module-name
$ puppet module upgrade puppetlabs-accounts
$ puppet module upgrade puppetlabs-accounts –version=v1.3.0

7. Uninstall puppet module

$ puppet module uninstall module-name
$ puppet module uninstall puppetlabs-accounts

reference:
https://puppet.com/docs/puppet/5.3/modules_installing.html#installing-modules-from-the-command-line

PHP unit test using Jenkins and Ansible script

 

1.1 Create the Jenkins Job

Jenkins -> New Item -> Freestype project – >

Enter the project name

 

1.2 At the Build section,  “Add build step” ->  Execute shell , enter the ansible-playbook details to be executed

1.3 In the “Post-build Actions” ->  “Add post-build actions” -> “Publish JUnit test result report” -> and set “Test reports XMLs” to the php unit test output xml file

2. Ansible playbook

– hosts: host1
vars:
base_dir: /projectdir/
tasks:
– name: run testrunner
shell: php vendor/bin/phpunit –log-junit results/phpunit/phpunit.xml
args:
chdir: “{{ base_dir }}/api”
register: phpunit_output
ignore_errors: yes

– name: rsync results/phpunit/phpunit.xml file to jenkins
command: rsync -vr root@host1:/project/results /var/lib/jenkins/jobs/Php-test/workspace/
delegate_to: localhost

 

eg: host1 , host where the php project is located

Puppet Agent install and configuration on CentOS/Redhat

1. Download the puppet agent from http://puppet.com
or go directly to https://puppet.com/download-puppet-enterprise/thank-you

2. Upload the rpm file to the server and run

rpm -ivh puppet-agent<version>.rpm

Note: Here I am using Centos 6.5 –  64bits OS

3. Configure puppet agent to point to the master server.
3.1   Open the file /etc/puppetlabs/puppet/puppet.conf and add the following entires

[main]
certname = puppetclient1.com
server = puppetmaster.com
environment = production
runinterval = 1h

3.2 Run puppet agent -t from the client

3.3 Accept the client cert from the Puppet master server

Installing Puppet Enterprise on Linux server

Installing Puppet Enterprise on Linux server

1.  Go to https://puppet.com/ and download the .tar.gz Puppet enterprise master and Agent installation      files.
eg: for centos7
 https://pm.puppetlabs.com/cgi-bin/download.cgi?dist=el&rel=7&arch=x86_64&ver=latest
2.  Upload the puppet-enterprise tar.gz file to the Puppet Master Server.
Here we are using a server installed with CentOS

3. untar the installation file

4. Now we will start the  Puppet Enterprise Master installation.
Go to the folder and run the installer file puppet-enterprise-installer

Note:  if you are not using a DNS server, add the entries for the IP address and hostname in the /etc/hosts files

5.  Press ‘Y’ to continue installation

6. As shown in the above pic, open a browser and go to the url mentioned.
Here we are opening https://puppetmaster:3000
Click “Let’s get started!”  to continue the installation.

Note: If you are accessing GUI from a different desktop/server make sure that the port 3000 and 443 ( for later use ) is open between them

7. Choose your deployment mode.
Since my environment is less than 7000 nodes,  I am using only 1 master server, I am going with Monolithic.

8. Enter the puppet master FQDN and Puppet master DNS alias.

Note: if you don’t have a DNS server, make sure that these entries are added to /etc/hosts file

9.  Enable Application Orchestration

10
10.1  Select the database support needed.
Here I am selecting the option to install the PostgresSQL and to create PuppetDB database on it      during the installation.
10.2 Enter the admin password, this is need to login to the Enterprise GUI console after installation.

11. Confirm the plan and click “continue”

11.  If there are no messages in red color, click “Deploy now”.

12. Now the Puppet entries is getting installed.

13. After installation you can login to the Puppet Enterprise GUI using https://puppetmaster url and user name as admin and password  given in step 10.2

 

Vagrant – running a vagrant box in windows 7

Vagrant  – running a box in windows 7

1.  Download and install virtual box from https://www.virtualbox.org/wiki/Downloads
and start up the virtual box.

2. Download and install vagrant from  http://downloads.vagrantup.com/

I had my vagrant installed in the location C:HashiCorpVagrant.
And added C:HashiCorpVagrant;C:HashiCorpVagrantbin to windows environment path.

3.  Also install putty from http://www.putty.org/   for SSH access to the box

4.  I had issues installing the box image using vagrant command, through internet. So I downloaded them and copied them and initiated it locally.

For this I created a project location C:HashiCorpVagrantProjectsVM

And I downloaded the box file or copied the box file from the url http://files.vagrantup.com/lucid32.box to the default box file location %userprofile%.vagrant.dboxes

5.  Add the downloaded box.
For this open the windows command prompt as administrator and add the box to vagrant list using command,

> vagrant box add lucid32 %userprofile%.vagrant.dboxeslucid32.box –provider virtualbox

  note : replace %userprofile% with the location to .vagrant.d folder

6.   Go to the project location C:HashiCorpVagrantProjectsVM and run the command

> vagrant init lucid32

it will create a vagrant configuration file in the current project location

7. Now start up the VM using the box image lucid32 by running the command

> vagrant up


8.  To get the ssh details run the command,

> vagrant ssh-config



9. Use the details got from the step 8 to ssh login using putty.

 username : vagrant
 password: vagrant



Now you are in the vm.