Dev Ops Commands
DevOPS
1. Git Commands
Branch
Branch is the separate flow where other people can work. When a branch is created from main or master then all the code of that point is copied to the branch. Any changes made in new branch will not affect in other branches. If the file is in the Workspace area then it will be visible to all the branches but once commit to a specific branch then only those branch can see the file no other can
- Git branch => to show all the branches
- Git branch branch-name => creates new branch
- Git checkout branch-name => shift to given Branch
- Git merge branch-name => Used to merge the given branch name with the current working branch
- Git stash => Used to move the current untracked code into local storage avaliblabe stash so that we can work on something else. Then later when something else is done we can take out the unsaved code from stash
- Git stash list => used to show all the stash avaialbes
- Git stash apply stash index => used to rollback a specific stash
- Git reset => used to move all the work from staging area back to workspace
- Git reset hard => used to undo the files that are added from workspace to staging area and delete them from workspace also
2. Linux Commands
- Touch —> create files empty
- Cat -> Read & concat files
- Cat temp1 > temp2 => copy content of temp1 in temp2
- Vi ( :wq) => to save and quite
- Vi ( :q!) => to unsafe and quit
- Create hidden file => add . In front of file and directory
- How to copy => cp source destination
- How to cut/paste => mv source destination
- Rmdir => used to remove the directory only if empty
- Rmdir -p => Remove both the parent and child directory
- Rmdir -pv => Remove all
- Rm -rf => Remove even non empty files and directory
- Yum update -y ==> Update all the packages
- Tree => Used to see the folder structure in form of tree
- Sort filename => Used to print content of file in sorted order
- Hostname -I => Used to see Ip Adress
- Ipconfig => Gives all information
- Which package name => tells directory if package is avalibalbe otherwise not available
- Groupadd group-name => Add Group
- Useradd username => Add the user into system
3. Chef Commands
Chef is the infrastrucutre as a code.
Resources: Basic component of receipe used to manage the basic infrastructure.
- Package : Manages the package on the node
- Service : Manages the services on the Node
- User: Manage the users in the Node
- Group: Manage the Groups on the Node
- Template: Manage the already existing templates of receipies
- Cookbook-file: Transfer the files from the file subdirectory in the cookbook to the location on the node
- File: Manage the files on the Node
- execute: Execute the command on the node
- cron: Edit and existing cron file on the node
- directory: Manages the directory on the node
How to setup Chef (Workstation ):
- https://community.chef.io/downloads/tools/workstation?os=el Download the chef
- Don’t Download it just copy the download url ( https://packages.chef.io/files/stable/chef-workstation/0.4.2/el/7/chef-workstation-0.4.2-1.el6.x86_64.rpm )
- Wget url ( it will download the same file from internet )
- Do ls you will se a .rpm pakacage downloaded.
- We just downloaded the package now we have to install this.
- Yum install .rpm file name
- After this connect the workstation with chef server
Commands:
- Chef generate cookbook name
- Chef generate recipe name
- Chef exec -c ruby location-of-recipe: Tells if the recipe syntax is okay
- Knife ssl check ( On Workstation ): Tell if the workstation is connected to chef-server
- Knife node list (On Workstation ) : Shows all nodes connected to server
- Knife bootstrap privateIpofNode —ssh-user username —sudo -I secretpemkey_of_node -N nodename ( Command used to connect the node to chef server and we have to connect the node to chef server from workstation only )
- scp -i /path/to/your/.pemkey -r /copy/from/path user@server:/copy/to/path
- Knife cookbook upload cookbook name ( command used to upload the cookbook from workstation to server )
- Knife cookbook list ( show all the cookbooks uploaded on the server )
- Add recipe in runlets of node: knife node run_list set nodename “recipe[cookbook::recipe]”
- Knife cookbook delete cookbookname -y
- Knife node delete nodename -y
Roles:
How to create a role:
Go inside the roles directory inside the chef-repo and create one new file
vi name.rb
description “Web Server”
run_list “recipe[cookbookname::recipename]”
1. How to upload the role on the server => knife role from file roles/filename
- Knife role list ( Give you all the roles )
- How to add a role with newly bootstrap Node: knife node run_list set nodename “role[rolename]”
- Knife cookbook upload nameofcoookbook : This cookbooks must be included in the role with which the nodes are connected.
Comments
Post a Comment