Search This Blog

Friday, 5 March 2021

What is a version control system ?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. 

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.

Local Version Control Systems

Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.
To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.




One of the most popular VCS tools was a system called RCS, which is still distributed with many computers today. RCS works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.

Centralized Version Control Systems

The next major issue that people encounter is that they need to collaborate with developers on other systems. To deal with this problem, Centralized Version Control Systems (CVCSs) were developed. These systems (such as CVS, Subversion, and Perforce) have a single server that contains all the versioned files, and a number of clients that check out files from that central place. For many years, this has been the standard for version control.



This setup offers many advantages, especially over local VCSs. For example, everyone knows to a certain degree what everyone else on the project is doing. Administrators have fine-grained control over who can do what, and it’s far easier to administer a CVCS than it is to deal with local databases on every client.

However, this setup also has some serious downsides. The most obvious is the single point of failure that the centralized server represents. If that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they’re working on. If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everything — the entire history of the project except whatever single snapshots people happen to have on their local machines. Local VCSs suffer from this same problem — whenever you have the entire history of the project in a single place, you risk losing everything.

Distributed Version Control Systems

This is where Distributed Version Control Systems (DVCSs) step in. In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history. Thus, if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data.



Furthermore, many of these systems deal pretty well with having several remote repositories they can work with, so you can collaborate with different groups of people in different ways simultaneously within the same project. This allows you to set up several types of workflows that aren’t possible in centralized systems, such as hierarchical models.

What is GIT ?

 Git is a version control system. The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes. These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as delta-based version control).

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.

Git stores data as snapshots of the project over time

This is an important distinction between Git and nearly all other VCSs. It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation. This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS. 

Nearly Every Operation Is Local

Most operations in Git need only local files and resources to operate  generally no information is needed from another computer on your network. If you’re used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers. Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.

For example, to browse the history of the project, Git doesn’t need to go out to the server to get the history and display it for you — it simply reads it directly from your local database. This means you see the project history almost instantly. If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally.

This also means that there is very little you can’t do if you’re offline or off VPN. If you get on an airplane or a train and want to do a little work, you can commit happily (to your local copy, remember?) until you get to a network connection to upload. If you go home and can’t get your VPN client working properly, you can still work. In many other systems, doing so is either impossible or painful. In Perforce, for example, you can’t do much when you aren’t connected to the server; in Subversion and CVS, you can edit files, but you can’t commit changes to your database (because your database is offline). This may not seem like a huge deal, but you may be surprised what a big difference it can make.

Git Has Integrity

Everything in Git is checksummed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. You can’t lose information in transit or get file corruption without Git being able to detect it.

The mechanism that Git uses for this checksumming is called a SHA-1 hash. This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. A SHA-1 hash looks something like this:

24b9da6552252987aa493b52f8696cd6d3b00373
You will see these hash values all over the place in Git because it uses them so much. In fact, Git stores everything in its database not by file name but by the hash value of its contents.

Git Generally Only Adds Data

When you do actions in Git, nearly all of them only add data to the Git database. It is hard to get the system to do anything that is not undoable or to make it erase data in any way. As with any VCS, you can lose or mess up changes you haven’t committed yet, but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.

This makes using Git a joy because we know we can experiment without the danger of severely screwing things up. For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see Undoing Things.

The Three States

Pay attention now — here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: modified, staged, and committed:
  1. Modified means that you have changed the file but have not committed it to your database yet.
  2. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
  3. Committed means that the data is safely stored in your local database.
This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory.




Working tree, staging area, and Git directory.

The working tree is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.

The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well.

The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

The basic Git workflow goes something like this:
  1. You modify files in your working tree.
  2. You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area.
  3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified and was added to the staging area, it is staged. And if it was changed since it was checked out but has not been staged, it is modified.

Thursday, 4 March 2021

Create a symlink using puppet programming

 Task:
Create a puppet programming file apps.pp under /etc/puppetlabs/code/environments/production/manifests directory on puppet master node i.e on Jump Server. Within that define a class symlink and perform below mentioned tasks:
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
}

Step 2) Validate the syntax 

root@jump_host /etc/puppetlabs/code/environments/production/manifests# puppet parser validate apps.pp

Step 3) Run puppet agent -tv on app server 1 and validate if the symlink and empty file is created. 

[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

Step 3) Run puppet agent -tv on app server 2 and validate if the symlink and empty file is created. 

[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 ~]# 

Step 3) Run puppet agent -tv on app server 3 and validate if the symlink and empty file is created. 

[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 ~]# 

Puppet





Wednesday, 3 March 2021

Ansible Loop examples

Simple Ansible playbook for demonstrating loop

[osboxes@master ansible-playbooks]$ cat install-packages.yml

---
- name: Install packages
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: Install http and redis packages
      yum:
        name: "{{ item }}"
        state: present
      loop:
        - epel-release
        - redis
        - httpd


[osboxes@master ansible-playbooks]$ ansible-playbook install-packages.yml -i inventory.txt -K
BECOME password:

PLAY [Install packages] *************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [Install http and redis packages] **********************************************************************************************************************
changed: [192.168.1.182] => (item=epel-release)
changed: [192.168.1.182] => (item=redis)
changed: [192.168.1.182] => (item=httpd)

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


Create a play book for package installation and define the packages under vars section and use it in a loop.

[osboxes@master ansible-playbooks]$ cat install-packages_1.yml
---
- name: Install packages
  hosts: all
  become: true
  become_user: root
  vars:
    required_packages:
      - epel-release
      - redis
      - httpd

  tasks:
    - name: Install http and redis packages
      yum:
        name: "{{ item }}"
        state: present
      loop: "{{ required_packages }}"

[osboxes@master ansible-playbooks]$ ansible-playbook install-packages_1.yml -i inventory.txt -K
BECOME password:

PLAY [Install packages] *************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [Install http and redis packages] **********************************************************************************************************************
ok: [192.168.1.182] => (item=epel-release)
ok: [192.168.1.182] => (item=redis)
changed: [192.168.1.182] => (item=httpd)

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Create a play book for Iterating over a list of hashes 

---
- name: Add multiple users belongs to different groups
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: Add users
      user:
        name: "{{ item.name }}"
        state: present
        groups: "{{ item.groups }}"
      loop:
        - { name: 'user1', groups: 'wheel' }
        - { name: 'user2', groups: 'root' }


[osboxes@master ansible-playbooks]$ ansible-playbook addusers.yml -i inventory.txt

PLAY [Add multiple users belongs to differnt groups] ********************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [Add users] ********************************************************************************************************************************************
changed: [192.168.1.182] => (item={'name': 'user1', 'groups': 'wheel'})
changed: [192.168.1.182] => (item={'name': 'user2', 'groups': 'root'})

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Playbook for Iterative over a dictionary 

[osboxes@master ansible-playbooks]$ cat dict.yml
---
- name: dict2items
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: dict2items
      debug:
        msg: "{{ item.key }} - {{ item.value }}"
      loop: "{{ tag_data | dict2items }}"
      vars:
        tag_data:
          Environment: dev
          Application: payment


[osboxes@master ansible-playbooks]$ ansible-playbook dict.yml -i inventory.txt --syntax-check

playbook: dict.yml

[osboxes@master ansible-playbooks]$ ansible-playbook dict.yml -i inventory.txt

PLAY [dict2items] *******************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [dict2items] *******************************************************************************************************************************************
ok: [192.168.1.182] => (item={'key': 'Environment', 'value': 'dev'}) => {
    "msg": "Environment - dev"
}
ok: [192.168.1.182] => (item={'key': 'Application', 'value': 'payment'}) => {
    "msg": "Application - payment"
}

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Registering variable with a loop

---
- name: Register loop output as a variable
  hosts: all
  become: true
  become_user: root
  tasks:

    - name: Register loop output
      shell: "echo {{ item }}"
      loop:
        - "one"
        - "two"
      register: echo

    - name: Show register variale echo results
      debug: var=echo

    - name: Fail if return code is not 0
      fail:
        msg: "The command ({{ item.cmd }}) did not have a 0 return code"
      when: item.rc != 0
      loop: "{{ echo.results }}"

    - name: Place the result of the current item in the variable
      shell: echo "{{ item }}"
      loop:
        - one
        - two
      register: echo
      changed_when: echo.stdout != "one"


[osboxes@master ansible-playbooks]$ ansible-playbook register.yml -i inventory.txt

PLAY [Register loop output as a variable] *******************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [Register loop output] *********************************************************************************************************************************
changed: [192.168.1.182] => (item=one)
changed: [192.168.1.182] => (item=two)

TASK [Fail if return code is not 0] *************************************************************************************************************************
skipping: [192.168.1.182] => (item={'cmd': 'echo one', 'stdout': 'one', 'stderr': '', 'rc': 0, 'start': '2021-03-03 19:30:37.399257', 'end': '2021-03-03 19:30:37.406175', 'delta': '0:00:00.006918', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'echo one', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['one'], 'stderr_lines': [], 'failed': False, 'item': 'one', 'ansible_loop_var': 'item'})
skipping: [192.168.1.182] => (item={'cmd': 'echo two', 'stdout': 'two', 'stderr': '', 'rc': 0, 'start': '2021-03-03 19:30:38.668798', 'end': '2021-03-03 19:30:38.676035', 'delta': '0:00:00.007237', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'echo two', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['two'], 'stderr_lines': [], 'failed': False, 'item': 'two', 'ansible_loop_var': 'item'})

TASK [Place the result of the current item in the variable] *************************************************************************************************
ok: [192.168.1.182] => (item=one)
changed: [192.168.1.182] => (item=two)

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=3    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0


Looping over inventory

[osboxes@master ansible-playbooks]$ cat inventory-loops.yml
---
- name:  looping over inventory
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: Show all the hosts in the inventory
      debug:
        msg: "{{ item }}"
      loop: "{{ groups['all'] }}"

    - name: Show all the hosts in the current play
      debug:
        msg: "{{ item }}"
      loop: "{{ ansible_play_batch }}"

    - name: Show all the hosts in the inventory
      debug:
        msg: "{{ item }}"
      loop: "{{ query('inventory_hostnames', 'all') }}"


[osboxes@master ansible-playbooks]$ ansible-playbook inventory-loops.yml -i inventory.txt

PLAY [looping over inventory] *******************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [192.168.1.182]

TASK [Show all the hosts in the inventory] ******************************************************************************************************************
ok: [192.168.1.182] => (item=192.168.1.182) => {
    "msg": "192.168.1.182"
}

TASK [Show all the hosts in the current play] ***************************************************************************************************************
ok: [192.168.1.182] => (item=192.168.1.182) => {
    "msg": "192.168.1.182"
}

TASK [Show all the hosts in the inventory] ******************************************************************************************************************
ok: [192.168.1.182] => (item=192.168.1.182) => {
    "msg": "192.168.1.182"
}

PLAY RECAP **************************************************************************************************************************************************
192.168.1.182              : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0






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:


Playbook is in encrypted format

[osboxes@master ansible-playbooks]$ cat myplaybook.yml
$ANSIBLE_VAULT;1.1;AES256
33323364653962656634346462396431306336343534663265646663356463623036656563313931
3264313266393965316435666439316661623763356164630a356463646366343662666637323263
34356433343061313432386262376566393536663930653030333863393130336563353931613466
3432343361613631620a396235363864663639306465396230366564666630616666336161316265
33613338666264323735326336303537353663363835316330393239666634366461383935373962
62646338663339333132646465343664613439316464373133633630656664663630343161633465
65316136653964313663363133636430663132393936326630656430383931373233646436663661
65663663383336643463653338326439353330376532363866663936366237646635386138383835
65363366616161393038656262373631633439356433336133653435626136616137633136336164
38623636326134633435306630613936313565376264666564303032383531393137666662653930
62323366343032613137393064353836396233313433666263396536666163666134313865383430
61333436626233633337323834633564636265333930333464366232663366326238313833363166
65633465666434616262303136383032643737653061323935373633353464653331


Command to view the exiting encrypted playbook

[osboxes@master ansible-playbooks]$ ansible-vault view  myplaybook.yml
Vault password:
---
- name: sample playbook
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: create a user
      user:
        name: pavan
        uid: 3405
        state: present

Create a new playbook and supply a ansible vault password from a file

[osboxes@master ansible-playbooks]$ cat password.txt
abcdef123

[osboxes@master ansible-playbooks]$ ansible-vault create mynewplaybook --vault-password-file=password.txt

Note: this will not prompt you for the password rather is uses the password from a file.

How to edit an exiting encrypted ansible playbook

[osboxes@master ansible-playbooks]$ ansible-vault edit mynewplaybook
Vault password:



How to encrypt existing plain text playbook or file


[osboxes@master ansible-playbooks]$ cat inventory.txt
linuxhost

[osboxes@master ansible-playbooks]$ ansible-vault encrypt inventory.txt
New Vault password:
Confirm New Vault password:
Encryption successful

[osboxes@master ansible-playbooks]$ cat inventory.txt
$ANSIBLE_VAULT;1.1;AES256
33363732386161363837306334323835353030636361626661656234646264656133316330346333
6430633838646432366338636162343861363363343633660a326531356235633338386234646466
63316530353162313635623466353465346161386363666239313931333533383532663763623565
6632653536396461340a373662323165663661616531663861626236623763646431623636313365
6137

How to decrypt an excising encrypted file

[osboxes@master ansible-playbooks]$ ansible-vault decrypt inventory.txt
Vault password:
Decryption successful

[osboxes@master ansible-playbooks]$ cat inventory.txt
linuxhost

How to encrypt a exiting file and output to a new file.

[osboxes@master ansible-playbooks]$ cat myplaybook.yml
---
- name: sample playbook
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: create a user
      user:
        name: pavan
        uid: 3405
        state: present
    - name; create a second user
      user:
      name: kumar
      uid: 3406
      state: present

[osboxes@master ansible-playbooks]$ ansible-vault encrypt myplaybook.yml --output=myplaybook-new.yml
New Vault password:
Confirm New Vault password:
Encryption successful

[osboxes@master ansible-playbooks]$ ansible-vault encrypt myplaybook.yml --output=myplaybook-new.yml
New Vault password:
Confirm New Vault password:
Encryption successful
[osboxes@master ansible-playbooks]$ cat myplaybook.yml
---
- name: sample playbook
  hosts: all
  become: true
  become_user: root
  tasks:
    - name: create a user
      user:
        name: pavan
        uid: 3405
        state: present
    - name; create a second user
      user:
      name: kumar
      uid: 3406
      state: present

[osboxes@master ansible-playbooks]$ cat myplaybook-new.yml
$ANSIBLE_VAULT;1.1;AES256
65346362393834646664663363623633376465636133353733333163643538646333386635356464
3766333336353132323830343139613966363034323062330a633664653731336564643738343638
63623463333666393931313061363232306263663036613534303065653930653066626634336633
3933656663353661350a663261626566383666333631623066313333356266306561626633323435
33356238326339396262666237616662646563306238356561386433363735633733626466376532
63363162353966616164613631646266636661646433646265396335316437333936613737386335
66666561363938303563613031333433343361393135623230626464323138386463643231353837
64663137656565373538386134653038326232353666613633643762346339383739383330313634
61373366353139633265623061323237653734393236383937663862646335633764313336356533
63633831626131623936663663323263313130363330376662383837383062323264636137366638
64333966326463643730356463613636623231643835356531616434616566383034376332636163
31633165363965336536356531356561663964666630313262633263636566323433653937653934
36636561303162346533313332303661343630303564306137353438643534393966356364346635
38373366616337623636363331316639376166373739376562313761623230343039336236376339
66373331343031616463326535363838653739623461643065306562353464656234333465393833
64376332376436643661633463393763303663643934333733383963663833326638313438656133
33613566383263616265363962356633356331383032343062336232333463316532373463633738
3632613562623837396338626136353833613762323861303337



How to change the password of encrypted file 

[osboxes@master ansible-playbooks]$ ansible-vault rekey  myplaybook-new.yml
Vault password:
New Vault password:
Confirm New Vault password:
Rekey successful

How to run encrypted playbook

[osboxes@master ansible-playbooks]$ cat linux-user.yml
$ANSIBLE_VAULT;1.1;AES256
66656130323264306261626638333937653734616232643762663164353661383537366634326439
3161363539653865346136353133313037623662653336360a393731373363343266383630653635
66353537313666306338303364633131376466376465373962323161353131646332643331303232
3436626635633631370a336361653664613633353661336631656234623332666438633134313564
31363161626330363437633739313961396438646537383566643862336634646134613831323538
65313364643363613363623937653439376363343266613065623236393237333236643532356666
66643231663631393935326537616261353432346434643861343036333964623061386335383336
63343062643930306539373537326661623238653333653564646635376232626638326534343633
37646434303633313138313433316561306362323537646162663939323837613664663362633261
31316130656461333162633239353834623464373563623832653234353362396139656362353333
36393034643938306535653636376465336133653335326363393637386633623466333862303765
63613531393839636661326562336266353966316561643830306435326565626164346532373135
35353561353563613166626362663535323932336262633737353363373734616464313137306537
34363634343564376636306138383365366636623135623930373063613236666539646337623737
306336363139613839663765623331666633

[osboxes@master ansible-playbooks]$ cat inventory.txt
linuxhost


[osboxes@master ansible-playbooks]$ ansible-playbook --vault-id @prompt linux-user.yml -i inventory.txt -K
BECOME password:
Vault password (default):

PLAY [Create a Linux User] **********************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]

TASK [User Account Creation] ********************************************************************************************************************************
changed: [linuxhost]

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0







Monday, 1 March 2021

Ansible playbook for creating a directory

 Step 1) Create a sample file on ansible master server.

[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 }}"

Step 3) Check the syntax

[osboxes@master ansible-playbooks]$ ansible-playbook create_dir.yml -i inventory.txt --syntax-check
playbook: create_dir.yml

Step 4) Run the playbook

[osboxes@master ansible-playbooks]$ ansible-playbook  create_dir.yml -i inventory.txt -K
BECOME password:

PLAY [create a directory and copy a file to remote hosts] ***************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]

TASK [Create a directory on remote host] ********************************************************************************************************************
changed: [linuxhost]

TASK [copy a file from ansible master to remote directory] **************************************************************************************************
changed: [linuxhost]

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


Step 5) Verify if the directory is created and file has been copied on the remote host

[osboxes@linuxhost tmp]$ ls -l /tmp/example/
total 0
-rw-r--r--. 1 root root 0 Mar  1 05:15 sample.txt

Saturday, 27 February 2021

Ansible playbook for apache installation using yum module

Step 1) Create a playbook

 [osboxes@master ansible-playbooks]$ cat>apache-install.yml
---
- hosts: all
  become: true
  become_user: root
  tasks:
       - name: Install httpd package
         yum:
           name: httpd
           state: present

       - name: Create a index.html
         copy:
           content: "Test page"
           dest: /var/www/html/index.html

       - name: Start httpd service
         service:
           name: httpd
           state: started
           enabled: true

- name: Test the webserver URL
  hosts: all
  become: no
  tasks:
    - name: Connect to http://<hostname>
      uri:
        url: http://localhost
        return_content: yes
        status_code: 200


Step 2) Verify the syntax

[osboxes@master ansible-playbooks]$ ansible-playbook apache-install.yml -i inventory.txt --syntax-check

playbook: apache-install.yml

Step 3) Execute the playbook with --step option to run to verify on the remote host after each step. 

[osboxes@master ansible-playbooks]$ ansible-playbook apache-install.yml -i inventory.txt -K --step
BECOME password:

PLAY [Apahce webserver installation] ************************************************************************************************************************
Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue: **************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]
Perform task: TASK: Install httpd package (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Install httpd package (N)o/(y)es/(c)ontinue: ********************************************************************************************

TASK [Install httpd package] ********************************************************************************************************************************
changed: [linuxhost]
Perform task: TASK: Create a index.html (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Create a index.html (N)o/(y)es/(c)ontinue: **********************************************************************************************

TASK [Create a index.html] **********************************************************************************************************************************
changed: [linuxhost]
Perform task: TASK: Start httpd service (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Start httpd service (N)o/(y)es/(c)ontinue: **********************************************************************************************

TASK [Start httpd service] **********************************************************************************************************************************
changed: [linuxhost]

PLAY [Test the webserver URL] *******************************************************************************************************************************
Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue: **************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]
Perform task: TASK: Connect to http://<hostname> (N)o/(y)es/(c)ontinue: y

Perform task: TASK: Connect to http://<hostname> (N)o/(y)es/(c)ontinue: *************************************************************************************

TASK [Connect to http://<hostname>] *************************************************************************************************************************
ok: [linuxhost]

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=6    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Ansible Playbook for Linux User Creation

Step 1) Create a simple playbook using user ansible module for user creation.

[osboxes@master ansible-playbooks]$ cat>linux-user.yml
---
- name: Create a Linux User
  hosts: all
  become: true
  become_user: root
  tasks:
      - name: User Account Creation
        user:
          name: pavan
          uid: 3405
          state: present

Step 2) Run the playbook using --syntax-check for syntax verification.

[osboxes@master ansible-playbooks]$ ansible-playbook linux-user.yml -i inventory.txt --syntax-check

playbook: linux-user.yml

Step 3) Run playbook using -C option for trial run. It will not perform actual task rather it will check if the task is going to be successful or failed. Here in the following example it says that task is going to be failed but it did not perform anything. Error is due to not providing -K option for asking password. 

[osboxes@master ansible-playbooks]$ ansible-playbook -C linux-user.yml -i inventory.txt

PLAY [Create a Linux User] **********************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
fatal: [linuxhost]: FAILED! => {"msg": "Missing sudo password"}

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

I did the trail run again and it says task is going to be successful. 

[osboxes@master ansible-playbooks]$ ansible-playbook -C linux-user.yml -i inventory.txt -K
BECOME password:

PLAY [Create a Linux User] **********************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]

TASK [User Account Creation] ********************************************************************************************************************************
changed: [linuxhost]

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Step 3) Now run the actual playbook task and verify if the user is created on remote host. 

[osboxes@master ansible-playbooks]$ ansible-playbook linux-user.yml -i inventory.txt -K
BECOME password:

PLAY [Create a Linux User] **********************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [linuxhost]

TASK [User Account Creation] ********************************************************************************************************************************
changed: [linuxhost]

PLAY RECAP **************************************************************************************************************************************************
linuxhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


Step 4) Verify if the linux user is created on remote host

[osboxes@linuxhost ~]$ id pavan
uid=3405(pavan) gid=1001(sftpusers) groups=1001(sftpusers)

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"

}

Step 2) Verify the syntax check before running actual playbook.

[osboxes@master ansible-projects]$ ansible-playbook install_configure_apache.yml -i webserver-inventory.txt --syntax-check

playbook: install_configure_apache.yml

Step 3) I have created a playbook for apache webserver installation and instance creation. You may download the source code from github repository.


[osboxes@master ansible-projects]$ cat install_configure_apache.yml
---
- hosts: all
  become: yes
  become_method: sudo

  roles:
    - role: "roles/apache24"


[osboxes@master ansible-projects]$ cat webserver-inventory.txt
webserverhost02




[osboxes@master roles]$ tree apache24/
apache24/
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   ├── boot.yml
│   ├── filesystem.yml
│   ├── install-dependencies.yml
│   ├── install.yml
│   ├── main.yml
│   └── validate.yml
├── templates
│   ├── apache.service.j2
│   └── httpd.conf.j2
├── tests
│   ├── inventory
│   └── test.yml
└── vars
    └── main.yml

8 directories, 15 files



Step 3) Run Ansible playbook for apache installation from source and instance creation. 


[osboxes@master ansible-projects]$ ansible-playbook install_configure_apache.yml -i webserver-inventory.txt

PLAY [all] **************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [webserverhost02]

TASK [roles/apache24 : check if the apache instance already present] ****************************************************************************************
ok: [webserverhost02]

TASK [roles/apache24 : fail] ********************************************************************************************************************************
skipping: [webserverhost02]

TASK [roles/apache24 : create a directory for apache binaries location] *************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : create a directory for apache instance location] *************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : create a directory for apache log location] ******************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Install all the packages] ************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Download apache binaries] ************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Download apr binaries] ***************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Download apr-util binaries] **********************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Install httpd package] ***************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Create a symlinks for apache products] ***********************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Install apr package] *****************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Copy apr package to srclib] **********************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Install apr-util package] ************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Copy apr-util package to srclib] *****************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Create a symlinks for python] ********************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Source code compilation] *************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Remove symlink] **********************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Configure Apache and change the desired installation location] ***********************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Execute the make command to prepare the files for the installation of Apache] ********************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Execute make install command to install apache] **************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : delete log directory] ****************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Create a log symlinks] ***************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : deploy httpd.conf.j2 to /home/osboxes/instances/apache24/poc-apache-instance/conf/] **************************************************
changed: [webserverhost02]

TASK [roles/apache24 : cleanup apache downloads] ************************************************************************************************************
changed: [webserverhost02] => (item=httpd-2.4.46.tar.gz)
changed: [webserverhost02] => (item=apr-1.7.0.tar.gz)
changed: [webserverhost02] => (item=apr-util-1.6.1.tar.gz)

TASK [roles/apache24 : Change the ownership for apache products directory] **********************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : Change the ownership for apache instances  directory] ********************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : deploy apache.service.j2 to /etc/systemd/system/apache.service] **********************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : load apache service] *****************************************************************************************************************
changed: [webserverhost02]

TASK [roles/apache24 : enable apache service] ***************************************************************************************************************
ok: [webserverhost02]

TASK [roles/apache24 : starting the apache instance] ********************************************************************************************************
changed: [webserverhost02]

PLAY RECAP **************************************************************************************************************************************************
webserverhost02            : ok=31   changed=28   unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

[osboxes@master ansible-projects]$


Step 4) Verify apache instance status on remote host

[osboxes@webserverhost02 ~]$ ps -ef | grep httpd
osboxes    63796       1  0 08:37 ?        00:00:00 /home/osboxes/instances/apache24/poc-apache-instance/bin/httpd -k start
osboxes    63797   63796  0 08:37 ?        00:00:00 /home/osboxes/instances/apache24/poc-apache-instance/bin/httpd -k start
osboxes    63798   63796  0 08:37 ?        00:00:00 /home/osboxes/instances/apache24/poc-apache-instance/bin/httpd -k start
osboxes    63799   63796  0 08:37 ?        00:00:00 /home/osboxes/instances/apache24/poc-apache-instance/bin/httpd -k start

[osboxes@webserverhost02 poc-apache-instance]$ curl -k http://webserverhost02:10001
<html><body><h1>It works!</h1></body></html>
[osboxes@webserverhost02 poc-apache-instance]$


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 4) Download or upload 





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

Step 1) I used ansible-galaxy to create a folder structure for tomcat playbook

[osboxes@master ansible-projects]$ ansible-galaxy init tomcat
- Role tomcat was created successfully

 [osboxes@master ansible-projects]$ tree tomcat/
tomcat/
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
    └── main.yml

8 directories, 8 files


Step 2) I have create playbook for tomcat installation and instance creation. You may download the source code from github repository.


[osboxes@master ansible-projects]$ cat install_configure_tomcat.yml
---
- hosts: all
  become: yes
  become_method: sudo

  roles:
    - role: "roles/tomcat90"


[osboxes@master ansible-projects]$ cat inventory.txt
tomcathost01



[osboxes@master ansible-projects]$ tree
.
├── install_configure_tomcat.yml
├── inventory.txt
└── roles
    └── tomcat90
        ├── defaults
        │   └── main.yml
        ├── files
        │   └── bash_profile
        ├── handlers
        │   └── main.yml
        ├── meta
        │   └── main.yml
        ├── README.md
        ├── tasks
        │   ├── boot.yml
        │   ├── filesystem.yml
        │   ├── install.yml
        │   ├── main.yml
        │   └── validate.yml
        ├── templates
        │   ├── setenv.sh.j2
        │   └── tomcat.service.j2
        ├── tests
        │   ├── inventory
        │   └── test.yml
        └── vars
            └── main.yml

10 directories, 17 files

Step 3) Run Ansible playbook 

[osboxes@master ansible-projects]$ ansible-playbook install_configure_tomcat.yml -i inventory.txt

PLAY [all] **************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [tomcathost01]

TASK [roles/tomcat90 : check if the tomcat instance already present] ****************************************************************************************
ok: [tomcathost01]

TASK [roles/tomcat90 : fail] ********************************************************************************************************************************
skipping: [tomcathost01]

TASK [roles/tomcat90 : create a directory for tomcat jdk location] ******************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : create a directory for tomcat product location] **************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : create a directory for tomcat product location] **************************************************************************************
ok: [tomcathost01]

TASK [roles/tomcat90 : create a directory for tomcat instance location] *************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : create a directory for tomcat log location] ******************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Installing Java] *********************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Create a symlink for jdk] ************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Copy bash_profile to destination server for setting up JAVA_HOME] ********************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Source the .bash_profile] ************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Download tomcat binaries] ************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Install tomcat] **********************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Create a symlinks for tomcat products] ***********************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Create a new tomcat instance] ********************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : delete log directory] ****************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : Create a log symlinks] ***************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : deploy setenv.sh.j2 to /home/osboxes/instances/poc-tomcat-instance/bin] **************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : cleanup tomcat downloads] ************************************************************************************************************
ok: [tomcathost01]

TASK [roles/tomcat90 : deploy tomcat.service.j2 to /etc/systemd/system/tomcat.service] **********************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : load tomcat service] *****************************************************************************************************************
changed: [tomcathost01]

TASK [roles/tomcat90 : enable tomcat service] ***************************************************************************************************************
ok: [tomcathost01]

TASK [roles/tomcat90 : starting the tomcat instance] ********************************************************************************************************
changed: [tomcathost01]

PLAY RECAP **************************************************************************************************************************************************
tomcathost01               : ok=23   changed=18   unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

Create a Linux user with expiration date

 Create a user named bandaru & Set expiry date to 2021-06-30

1) Create the user

[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

3) Set the expiration date

[root@tomcathost01 ~]# chage -E 2021-06-30 bandaru

4) Validate the expiration date

[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

Step 2) Once downloaded and installed, set up Git LFS for your user account by running:

pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)

$ git lfs install

Updated git hooks.

Git LFS initialized.

Step 3) In each Git repository where you want to use Git LFS, select the file types you'd like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime.

pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk (master)

$ git lfs track "*.gz"

Tracking "*.gz"


Now make sure .gitattributes is tracked:

pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)

$ git add .gitattributes

Step 4) Just commit and push to GitHub as you normally would; for instance, if your current branch is named main:

pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (master)

$ git add jdk-8u281-linux-x64.tar.gz

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

$ git push origin master
Username for 'https://github.com': pavanbandaru
Password for 'https://pavanbandaru@github.com':
Uploading LFS objects: 100% (1/1), 144 MB | 0 B/s, done.
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 424 bytes | 424.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/pavanbandaru/tomcat/pull/new/master
remote:
To https://github.com/pavanbandaru/tomcat.git/
 * [new branch]      master -> master

pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk8 (master)



GIT and GITHUB






Linux System Admin