Puppet Module Lab & Excercise – Part 1

Puppet Module Lab & Excercise – Part 1

  1. Write a puppet module to setup a webserver(httpd) only in RHEL and use the HEREDOC to craete a html code of index.html inside a directory called “/var/www/html/index.html”

  2. Write a puppet module to setup a webserver(httpd) only in RHEL and use the puppet template to create a html code of index.html inside a directory called “/var/www/html/index.html”

  3. Write a puppet module to install git, ntp and wget tools.

  4. Write a puppet module which has file named with deploy.sh under module’s files directory. the file should be copied to /opt

Tagged : / / / /

Puppet Program Lab & Excercise – Part 2

Puppet Program Lab & Excercise – Part 1

  1. Write a puppet Program to install package “git”, “ntp” and wget in RHEL.

  2. Which resource declaration can help us to deploy the “~/.ssh/authorized_keys” in 1000s of servers?

  3. Write a puppet Program to extract a tar ball in /opt

  4. Write a puppet Program to zip a directory which has multiple files.

  5. Write a puppet Program to reboot the machine?

  6. Write a puppet program to execute a shell command/script using puppet.

Tagged : / / / /

Puppet Program Lab & Excercise – Part 1

Puppet Program Lab & Excercise – Part 1

  1. Write a Puppet Program to create a file named with “file.txt” in /opt/ owner by ec2-user and execute permission?
  2. Write a Puppet Program to create a group called “scmgalaxy-admins”
  3. Write a Puppet Program to create a usser called “deploy” which should be a part of “scmgalaxy-admins” group.
  4. Wrire a Puppet Program and insert following in /etc/hosts
    10.4.5.5 test.scmgalaxy.com
  5. Write a puppet program to display following lines when Sends an arbitrary message to the agent run-time log.
    Welcome to scmGalaxy Puppet program
Tagged : / / / /

Enforce the JIRA issue id in a GIT commit message

Enforce the JIRA issue id in a GIT commit message

This can be done by using git hooks file location at .git/hooks/commit-msg. Following are the 2 way in whcih each Developers can set the Hooks in their developement envioronment.

Method – 1

# commit-msg.sh
#!/bin/sh
# This hook will make sure that the commit message contains a JIRA issue.
#
# To enable this hook, rename this file to ".git/hooks/commit-msg".
# Make sure to add execution permissions to the file.

export MESSAGE=$(<$1)
export JIRA_ISSUE_TAG='ISSUETAG-([0-9]*)'

if [[ $MESSAGE =~ $JIRA_ISSUE_TAG ]]; then
echo -e "\e[32mGreat, your commit message contains a JIRA issue!\e[0m"
exit 0;
fi

echo -e "\e[31mOh hamburgers ... You forgot to add a JIRA issue number!\e[0m";
exit 1;

Method 2 – This is another very good example to implement to force jira id in each commit message. http://nsbogan.com/tools/2015/06/04/jira-id-in-git-commit-messages

Tagged : / / / /

Best Branching and Merging strategies in Gerrit

Best Branching and Merging strategies in Gerrit

Step 1 – First Lets read this article about Best Branching and Merging strategies in git

Best Branching and Merging strategies in git

Step 2 – Now Lets learn the Gerrit Merge Types
https://nofluffjuststuff.com/magazine/2016/04/understanding_and_applying_gerrit_part_3_gerrit_submit_types_and_git_review

Step 3 – Time to Learn the Types of Submit in Gerrit
https://gerrit-review.googlesource.com/Documentation/project-configuration.html

Step 4 – Finally, You must read the recommendations below
https://hyperledger-fabric.readthedocs.io/en/release-1.2/Gerrit/best-practices.html

Tagged : / / / / /

Best Branching and Merging strategies in git

Best Branching and Merging strategies in git

Step 1 – First you need to learn the needs of branches. This is very good read.

  • https://docs.microsoft.com/en-us/vsts/repos/tfvc/branching-strategies-with-tfvc?view=vsts

Step 2 – Now time has come to Learn best branching model in Git.

  • https://buddy.works/blog/5-types-of-git-workflows
  • https://hackernoon.com/a-branching-and-releasing-strategy-that-fits-github-flow-be1b6c48eca2
  • https://nvie.com/posts/a-successful-git-branching-model/

Step 3 – Now, Lets understand, what is the kind of merges we have in Git?

  • https://www.atlassian.com/git/tutorials/using-branches/git-merge
  • https://git-scm.com/docs/merge-strategies
  • https://stackoverflow.com/questions/366860/when-would-you-use-the-different-git-merge-strategies

Step 4 – Are you still having a questions, Please post in the comment section.

Tagged : / / / / / / /

How to revert the changes once its submitted in Gerrit

How to revert the changes once its submitted in Gerrit

The Revert button is available if the change has been submitted. This Reverts the change via creating a new one. When the Revert button is pressed, a panel will appear to allow the user to enter a commit message for the reverting change.

Once a revert change is created, the original author and any reviewers of the original change are added as reviewers and a message is posted to the original change linking to the revert.

However, patchsets can not be reverted. so first you have to checkout one of the previous patchset. you can get the command from Gerrit review board at each patchset download panel. After checking it out amend it to generate new commit hash then pushed again as a new patchset.

If I have multiple patch set versions for one change in Gerrit, You can only submit the latest patch set version. The design assumes that the most recent patch set is the one developers will review and test, and as such older patch sets can not be submitted.

Good Read
http://www.saros-project.org/node/155

Tagged : / / / / / /

What is a Change and Patch set in Gerrit?

Here is the short and quick description of Gerrit key teminology.

Change

Every time you push a commit with a new Change-Id Gerrit allocates a new change. Every change has a unique Change-Id and a Change Number. The change contains a number of patch sets, comments on the patch sets and a code review rating (+2, +1, 0, -1, -2). Each change has a dedicated page that shows information about it called individual change page. This includes dependencies between different changes, patch sets and the review comments.

Submit

Once a change has received a +2 in the Code Review and no negative voting in the other categories the last patchset can be submitted. This means Gerrit will now try to cherry-pick your patch set and mark the change as merged.

Patch set

If you want to modify your change, you don’t have to push a new change to Gerrit but only a new patch set . Imagine a patch sets as different versions or revisions of a change. Each patch set can receive inline comments. Gerrit uses the Change-Id of a commit message to identify patch sets of a change. This is why all patch sets of a change have the same Change-Id.

To create a new Patch when new changes are submitted
Step 1: Install commit-msg hooks for gerrit

$ scp -p -P 29418 localhost:hooks/commit-msg .git/hooks/

 

 

Step 2: Create normal commit and push (for Patchset1)

for example:

git add Server.java
git commit -m "server added"
git push origin HEAD:refs/for/master

 

 

Step 3: After doing some changes to Server.java

Finally to create new Patchset (Patchset 2)

git add Server.java
git commit --amend
git push origin HEAD:refs/for/master
Repeat step 3 for further Patches

Understanding the Patch set in Git perspective

Git is a very advanced distributed source code control system. Maintaining patch sets (often called a topic branch) in Git. Git includes a rebase capability that is very useful for a number of different operations related to maintaining a branch of code including moving a branch forward, moving a branch around on an upstream branch to look for breakage, and merging changesets to create patch files.

Git: How to create and apply patches

Creating a patch

Make your changes and commit them.
Run $ git format-patch COMMIT_REFERENCE #to convert all commits since the referenced commit (not including it) into patch files.
$ git format-patch HEAD~~

This will create 2 files, one for each commit since HEAD~~, like these:
0001-make-stuff-more-awesome.patch
0002-allow-users-to-be-locked.patch

Applying patches
You can use git apply some.patch to have the changes from the .patch file applied to your current working directory. They will be unstaged and need to be committed by you.

To apply a patch as a commit (with its commit message), use git am some.patch. \
For all patches to be applied, simply run:
$ git am *.patch

Note that in some previous version you could pass the latest patch filename of a list of patches to apply all previous patches as wel
$ git am 0002-allow-users-to-be-locked.patch # May no longer work for you

You then have the 2 unpushed commits from the patch file created earlier.

Tagged : / / / /

How to replace Changes after the Gerrit review without changing the commit id?

How to replace Changes after the Gerrit review without changing the commit id?

One of the main benefits of code review is the ability to receive and incorporate feedback from other developers without changing the commit-id and review id. With Gerrit, you incorporate these changes by amending the commit. Gerrit uses the CHange-Id to ensure that each iteration of the commit are stored together as patchsets.

The process of modify same commit and commit message on gerrit after patchset creation is pretty straight forward.

Step 1 – Do the required modification in the code based on the review.

Step 2 – Add files using git add commands.

$ git add filename

Step 3 – Command to update/amend the most recent commit.

$ git commit --amend

When amending a commit with git commit –amend, leave the Change-Id line unmodified in the commit message. This will allow Gerrit to automatically update the change with the amended commit.

Step 4 – Gerrit updates the commit under review with your latest changes.

$ git push origin HEAD:refs/for/master
$ git push origin HEAD:refs/for/[BRANCH_NAME]
Tagged : / / / / / / /

How to update or pull current branch before committing in Git?

Best practice says that before you commit in git, you need to either do git pull or git fetch/merge. However, there is a way to find out wheather your branches is not in sync with remote.

To check the remote repo status you are really simulating a “fetch”
$ git fetch -v –dry-run

To bring your remote refs up to date
$ git remote -v update

This command will print whether the branch you are tracking is ahead, behind or has diverged with remote. If it says nothing, the local and remote are the same.
$ git status -uno

To pull
$ git pull origin <<branchname>>
or
$ git fetch origin <<branchname>>
$ git merge remote/<<branchname>>
$ git commit

Compare the two branches:
$ git log HEAD..origin/master –oneline

Tagged : / / / / / /