If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead.
Search This Blog
Friday, 5 March 2021
What is a version control system ?
If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead.
What is GIT ?
Storing data as changes to a base version of each file
Git doesn’t think of or store its data this way. Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem. With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots.
- Modified means that you have changed the file but have not committed it to your database yet.
- Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
- Committed means that the data is safely stored in your local database.
- You modify files in your working tree.
- You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area.
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Thursday, 4 March 2021
Create a symlink using puppet programming
Create a symbolic link through puppet programming code. The source path should be /opt/data and destination path should be /var/www/html on all Puppet agents i.e on all App Servers.
Create a blank file media.txt under /opt/data directory on all puppet agent nodes i.e on all App Servers.
Note: Please perform this task using apps.pp only, do not create any separate inventory file.
Step 1) Create puppet class file apps.pp on jump host where puppet master is running
root@jump_host /# cd /etc/puppetlabs/code/environments/production/manifests
root@jump_host /etc/puppetlabs/code/environments/production/manifests# cat>apps.pp
class symlink {
# create a symlink
file { '/opt/data/':
ensure => 'link',
target => '/var/www/html',
}
#media.txt file creation
file { '/opt/data/media.txt':
ensure => 'present',
content => '',
}
}
node 'stapp01.stratos.xfusioncorp.com', 'stapp02.stratos.xfusioncorp.com', 'stapp03.stratos.xfusioncorp.com' {
include symlink
}
[root@stapp01 ~]# puppet agent -tv
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for stapp01.stratos.xfusioncorp.com
Info: Applying configuration version '1614862700'
Notice: /Stage[main]/Symlink/File[/opt/data/]/ensure: created
Notice: /Stage[main]/Symlink/File[/opt/data/media.txt]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
Notice: Applied catalog in 0.05 seconds
[root@stapp01 ~]# cd /opt/data
[root@stapp01 data]# ls -rlt
total 0
-rw-r--r-- 1 root root 0 Mar 4 12:58 media.txt
[root@stapp01 data]# cd /var/www/html/
[root@stapp01 html]# ls -rlt
total 0
-rw-r--r-- 1 root root 0 Mar 4 12:58 media.txt
[root@stapp01 html]# cd ..
[root@stapp01 www]# ls -rlt
total 4
drwxr-xr-x 2 root root 4096 Mar 4 12:58 html
[root@stapp01 www]# cd /opt/
[root@stapp01 opt]# ls -rlt
total 8
drwxr-xr-x 1 root root 4096 May 23 2020 puppetlabs
lrwxrwxrwx 1 root root 13 Mar 4 12:58 data -> /var/www/html
[root@stapp02 ~]# puppet agent -tv
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for stapp02.stratos.xfusioncorp.com
Info: Applying configuration version '1614862834'
Notice: /Stage[main]/Symlink/File[/opt/data/]/ensure: created
Notice: /Stage[main]/Symlink/File[/opt/data/media.txt]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
Notice: Applied catalog in 0.04 seconds
[root@stapp02 ~]# ls /opt/data
media.txt
[root@stapp02 ~]# ls /var/www/html/
media.txt
[root@stapp02 ~]#
[root@stapp03 ~]# puppet agent -tv
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for stapp03.stratos.xfusioncorp.com
Info: Applying configuration version '1614862936'
Notice: /Stage[main]/Symlink/File[/opt/data/]/ensure: created
Notice: /Stage[main]/Symlink/File[/opt/data/media.txt]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
Notice: Applied catalog in 0.06 seconds
[root@stapp03 ~]# ls /opt/data
media.txt
[root@stapp03 ~]# ls /var/www/html/
media.txt
[root@stapp03 ~]#
Wednesday, 3 March 2021
Ansible Loop examples
Simple Ansible playbook for demonstrating loop
[osboxes@master ansible-playbooks]$ cat install-packages.yml
Ansible vault examples
Create a new playbook with ansible vault command to encrypt
[osboxes@master ansible-playbooks]$ ansible-vault create myplaybook.yml
New Vault password:
Confirm New Vault password:
Monday, 1 March 2021
Ansible playbook for creating a directory
[osboxes@master ansible-playbooks]$ touch /tmp/sample.txt
Step 2) Create a playbook
---
- name: create a directory and copy a file to remote hosts
hosts: all
become: yes
become_user: root
vars:
remote_dir: /tmp/example
sample_file: /tmp/sample.txt
tasks:
- name: Create a directory on remote host
file:
path: "{{ remote_dir }}"
type: directory
recurse: true
- name: copy a file from ansible master to remote directory
copy:
src: "{{ sample_file }}"
dest: "{{ remote_dir }}"
Saturday, 27 February 2021
Ansible playbook for apache installation using yum module
Ansible Playbook for Linux User Creation
Wednesday, 24 February 2021
Ansible playbook for apache webserver installation and configuration from source
Step 1) Copy ssh keys to remote target server.
[osboxes@master ansible-projects]$ ssh-copy-id webserverhost02
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/osboxes/.ssh/id_rsa.pub"
The authenticity of host 'webserverhost02 (192.168.1.246)' can't be established.
ECDSA key fingerprint is SHA256:QYhfRimq4gvWwsjg+kul52yjv48WfbcRHaaKgSuUQeE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
osboxes@webserverhost02's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'webserverhost02'"
and check to make sure that only the key(s) you wanted were added.
Step 2) Execute ansible ping module to check the remote server connectivity
[osboxes@master ansible-projects]$ ansible all -m ping -i webserver-inventory.txt
webserverhost02 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
[osboxes@master ansible-projects]$ ansible-playbook install_configure_apache.yml -i webserver-inventory.txt --syntax-check
playbook: install_configure_apache.yml
Atom IDE for developing Ansible playbooks
Step 1) Download and Install Atom
https://atom.io/download/windows_x64
Step 2) Create a Project folder and Remote Sync to Linux machine where you have ansible-projects
Step 3) Enter remote machine details for connectivity
Step 5) Configurations will automatically be saved on remote machine when you save the file on local system.
Sunday, 21 February 2021
Ansible playbook for tomcat installation and configuration
Create a Linux user with expiration date
Create a user named bandaru & Set expiry date to 2021-06-30
[root@tomcathost01 ~]# useradd bandaru
[root@tomcathost01 ~]# passwd bandaru
Changing password for user bandaru.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2) Check the expiry date for the user
[root@tomcathost01 ~]# chage -l bandaru
Last password change : Feb 21, 2021
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@tomcathost01 ~]# chage -E 2021-06-30 bandaru
[root@tomcathost01 ~]# chage -l bandaru
Last password change : Feb 21, 2021
Password expires : never
Password inactive : never
Account expires : Jun 30, 2021
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
Saturday, 20 February 2021
How to upload a file larger than 25mb into github
Step 1) Download and install git-lfs
https://github.com/git-lfs/git-lfs/releases/download/v2.13.2/git-lfs-windows-v2.13.2.exe
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk (master)
$ ls -lart
total 140388
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:08 ../
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:09 .git/
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:09 ./
-rw-r--r-- 1 pavankumar bandaru 197121 143722924 Feb 20 16:09 jdk-8u281-linux-x64.tar.gz
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)
$ git lfs install
Updated git hooks.
Git LFS initialized.
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk (master)
$ git lfs track "*.gz"
Tracking "*.gz"
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)
$ git add .gitattributes
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (master)
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (master)
$ git commit -m "jdk8"
[master (root-commit) fac4ee2] jdk8
2 files changed, 4 insertions(+)
create mode 100644 .gitattributes
create mode 100644 jdk-8u281-linux-x64.tar.gz