In this article we going to start new chapter about JavaScript and you can see our JavaScript tutorial on YouTube.  Let's know first basic thing about JavaScript.

JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.

JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.

The standards for JavaScript are the ECMAScript Language Specification (ECMA-262) and the ECMAScript Internationalization API specification (ECMA-402). The JavaScript documentation throughout MDN is based on the latest draft versions of ECMA-262 and ECMA-402.

JavaScript is the world's most popular programming language.

JavaScript is the programming language of the Web.

JavaScript is easy to learn. 

Why Study JavaScript?

JavaScript is one of the 3 languages all web developers must learn:

1. HTML to define the content of web pages

2. CSS to specify the layout of web pages

3. JavaScript to program the behavior of web pages

 GIT Commands

In this article we will see git commands from beginner to advance. It's important to know everyone if you are developer or devops.

1. git config

Command: git config –global “[name]”  

Command: git config –global “[email address]”  

This command sets the author name and email address respectively to be used with your commits.

2. git init

Command: git init [repository name]

This command is used to start a new repository.

3. git add

Command: git add [file]  

This command adds a file to the staging area.

Command: git add *  

This command adds one or more to the staging area.

4. git commit

Command: git commit -m “[ Type in the commit message]”  

This command records or snapshots the file permanently in the version history.

Command: git commit -a  

This command commits any files you’ve added with the git add command and also commits any files you’ve changed since then.

5. git diff

Command: git diff  

This command shows the file differences which are not yet staged.

Command: git diff –staged 

This command shows the differences between the files in the staging area and the latest version present.

Command: git diff [first branch] [second branch]  

This command shows the differences between the two branches mentioned.

6. git reset

Command: git reset [file]  

This command unstages the file, but it preserves the file contents.

Command: git reset [commit]  

This command undoes all the commits after the specified commit and preserves the changes locally.

Command: git reset –hard [commit]  

This command discards all history and goes back to the specified commit.

7. git status

Command: git status  

This command lists all the files that have to be committed.

8. git rm

Command: git rm [file]  

This command deletes the file from your working directory and stages the deletion.

9. git log

Command: git log  

This command is used to list the version history for the current branch.

Command: git log –follow[file]  

This command lists version history for a file, including the renaming of files also.

10. git show

Command: git show [commit]  

This command shows the metadata and content changes of the specified commit.

11. git tag

Command: git tag [commitID]  

This command is used to give tags to the specified commit.

12. git branch

Command: git branch  

This command lists all the local branches in the current repository.

Command: git branch [branch name]  

This command creates a new branch.

Command: git branch -d [branch name]  

This command deletes the feature branch.

13. git checkout

Command: git checkout [branch name]  

This command is used to switch from one branch to another.

Command: git checkout -b [branch name]  

This command creates a new branch and also switches to it.

14. git merge

Command: git merge [branch name]  

This command merges the specified branch’s history into the current branch.

15. git remote

Command: git remote add [variable name] [Remote Server Link]  

This command is used to connect your local repository to the remote server.

16. git push

Command: git push [variable name] master  

This command sends the committed changes of master branch to your remote repository.

Command: git push [variable name] [branch]  

This command sends the branch commits to your remote repository.

Command: git push –all [variable name]  

This command pushes all branches to your remote repository.

Command: git push [variable name] :[branch name]  

This command deletes a branch on your remote repository.

17. git pull

Command: git pull [Repository Link]  

This command fetches and merges changes on the remote server to your working directory.

18. git stash

Command: git stash save  

This command temporarily stores all the modified tracked files.

Command: git stash pop  

This command restores the most recently stashed files.

Command: git stash list  

This command lists all stashed change sets.

Command: git stash drop  

This command discards the most recently stashed change set.

19. git clone

Command: git clone [url]  

This command is used to obtain a repository from an existing URL.

Ansible Playbook Roles

In this article, we will read about ansible-playbook roles. what is this and how does it work.

Roles let you automatically load related vars, files, tasks, handlers, and other Ansible artifacts based on a known file structure. After you group your content into roles, you can easily reuse them and share them with other users.

Roles provide a framework for fully independent, or interdependent collections of variables, tasks, files, templates, and modules.

In Ansible, the role is the primary mechanism for breaking a playbook into multiple files. This simplifies writing complex playbooks, and it makes them easier to reuse. The breaking of the playbook allows you to logically break the playbook into reusable components.

An Ansible role has a defined directory structure with eight main standard directories. You must include at least one of these directories in each role. You can omit any directories the role does not use.

For example:

# playbooks

tasks/main.yml - the main list of tasks that the role executes.

handlers/main.yml - handlers, which may be used within or outside this role.

library/ - modules, which may be used within this role.

defaults/main.yml - default variables for the role. These variables have the lowest priority of any variables available and can be easily overridden by any other variable, including inventory variables.

vars/main.yml - other variables for the role.

files/main.yml - files that the role deploys.

templates/main.yml - templates that the role deploys.

meta/main.yml - metadata for the role, including role dependencies.


[user@ip]# mkdir -p playbook/roles/webserver/tasks

[user@ip]# tree                      (It will show tree hierarchy of playbook roles)

[user@ip]# cd playbook/

[user@ip playbook]# touch roles/webserver/tasks/main.yml

[user@ip playbook]# touch master.yml

[user@ip playbook]# vi roles/webserver/tasks/main.yml

inside main.yml type

-name: install apache
yum: pkg=httpd state=latest

and the save it and exit

[user@ip playbook]# vi master.yml

--- #Playbook Roles
- host: all
  user: ansible
 become: yes
 connection: ssh
    - webserver

and then save it and exit

[user@ip playbook]# ansible-playbook master.yml

 Ansible Playbook Vault

In this article, we will read about ansible-playbook vault. what is a vault and how to write code ansible-playbook vault.

Ansible allows keeping sensitive data such as passwords or keys in encrypted files rather than plain text in your playbooks.

Creating a new encrypted playbook
#ansible-vault create vault.yml

Edit the encrypted playbook
#ansible-vault edit vault.yml

To change the password encrypted playbook
#ansbile-vault rekey vault.yml

To encrypt an existing playbook
#ansible-vault encrypt vault.yml

To decrypt an encrypted playbook
#ansible-vault decrypt target.yml

Ansible Playbooks conditions

In this article, we will see ansible-playbook condition which is more important and whenever we have different scenarios, we put conditions according to the scenario.


When statement

Sometimes you want to skip a particular command on a particular node.

--- # Condition Playbook

- hosts: demo
  user: ansible
  become: yes
  connection: ssh
        - name: install apache on debian
          command: apt-get -y apache2
          when: ansible_os_family=="Debian"
        - name: install apache for redhat
          command: yum -y install https
          when: ansible_os_family=="RedHat"

See diagram for your reference that how to write code in playbook and output after execution file.

Ansible Playbook

Playbooks are the files where Ansible code is written. Playbooks are written in YAML format. YAML stands for Yet Another Markup Language. It is human-readable data serialization language and commonly used for configuration files.

Playbook is like a file where you write codes consist of vars, tasks, handlers, files, templates and roles.

Each playbook is composed of one or more modules in a list and Module is a collection of configuration files.

Playbooks are divided into many sections such as -

Target Section = Defines that host against which playbooks task has to be executed

Variable Section = variables are names used to hold one or more values

Task Section = List of all modules that we need to run in order.

YAML (Yet another Markup Language)

For ansible, nearly every YAML files start with a list. Each item in the list is a list of key-value pairs commonly call a dictionary. 

All YAML files have to begin with "---" and end with "..."

All members of a listed line must begin with the same indentation level starting with "-"

for example:

--- # A list of fruits
        - Apple
        - Mango
        - Banana
        - Pineapple
        - Grapes

A dictionary is represented in a simple key: value form

for example:

--- # A list of customer
- customer:
        name: Rakesh
        job: Trainer
        skills: Ansible
        exp: 7 years

Extension for playbook files is .yml

Note:- There should be space between : and value

[user@ip]# vi target.yml

--- # First Test playbook
    - hosts: demo
      user: ansible
      become: yes
      connection: ssh
      gather_facts: yes

now to execute this playbook

[user@ip]# ansible-playbook target.yml