Posts

Showing posts with the label devopsbykk

What is Terraform & Why Terraform : Scenario Based Interview Question & Answer

For our project, we create infra like S3 buckets and our networks and servers. Like these, there are so many requirements in my project. Previously we were working with different services based on the cloud platform. Suppose I am creating infrastructure in AWS; we just used CloudFormation, like in Azure We used Azure Resource Manager and GCP; we used Google Cloud Deployment Manager...like that we were working on our project. but right now in my latest project, we implemented a new style infra creation  using only one software tool across all the cloud platforms like AWS, Azure, and GCP. The software tool name is Terraform. terraform is a infrastructure creation software tool which we are using in my current project With the help of this Terraform, we are creating our project infrastructure, like S3 buckets, networks, services, and so on. Previously we were spending a lot of time to crate infrastructure by using respective cloud services ...instead of using all these services, we ju...

Ansible Modules Part-1

 1. Copy module: Copies files from the control machine to the target host. like deploying a configuration file. 2. Package module: Irrespective of the operating system, it selects the appropriate package module and installs, upgrades, or removes software. 3. Service module: manages services like start, stop, restart, enable 4. User module: Manages user accounts like create, deleting, and modifying user accounts 5. yum/apt module: Install or remove upgrade packages like Debian-based and red hat based environments.

How Ansible Modules Work

How Ansible Modules Work Execution Flow: whenever  y ou execute a playbook or run an ad-hoc command 2. Ansible copies the module to the target host 3. The module executes on the remote system 4. Results are returned to the Ansible control node

Ansible Playbook to install java software

  playbook name: java.yaml  ---  - name: remove java    hosts: all    become: yes    tasks:         - name: remove java         yum:               name: java-24-amazon-corretto              state: absent              autoremove: yes playbook name: java.yaml Execute playbook: ansible-playbook removejava.yaml Result: java software will be installed. 

Ansible Playbook to remove specific java version

playbook name:removejava.yaml  ---  - name: remove java    hosts: all    become: yes    tasks:         - name: remove java         yum:              name: java-24-amazon-corretto             state: absent             autoremove: yes playbook name:removejava.yaml execute playbook: ansible-playbook removejava.yaml Result: java software & deps also removed  autoremove: yes ---> means leftover files                                     and unnecessary files will be removed

Write Ansible Playbook using tags - (skip a specific task by using tag)

playbook name: task2.yaml --- - name: install packages   hosts: all   become: yes   tasks:     - name: install httpd       yum:            name: httpd            state: absent           tags: httpd     - name: install docker       yum:            name: docker            state: absent           tags: docker     - name: install java        yum:             name: java             state: present            tags: java      we have 3 tasks 1) Install httpd 2) Install docker 3) Install java but I would like to execute skip java execution task by using tag name step1: create playbook:        ex: playbo...

Write Ansible Playbook using tags - (execute a specific task by using tag)

 playbook name: task1.yaml --- - name: install packages   hosts: all   become: yes   tasks:     - name: install httpd       yum:          name: httpd          state: present         tags: httpd     - name: install docker       yum:          name: docker          state: present         tags: docker Note: we have two tasks 1) Install httpd 2) Install docker but I would like to execute only docker task by using tag name step1:  create playbook:             ex: playbook name: task1.yaml step2:  execution process:             ansible-playbook task1.yaml --tags docker step3:  result:        only docker software will be installed on target machines vist our YouTube Channel: https://www.youtube....

Write a Ansible Playbook to Install Docker & Start Docker Service

 1st Model: Install Docker & Start Docker Service  ==================================== Playbook Name: install_docker.yaml ---  - name: install docker & start docker service    hosts: all    become: yes    tasks:       - name: install docker package           yum:              name: docker             state: latest       - name: start docker service          service:             name: docker            state: started 2nd Model: Install Docker & Start Docker Service  ==================================== ---  - name: install docker & start docker service    hosts: all    become: yes    tasks:       - name: install docker package         ...

Write an Ansible Playbook to create multiple users

1st model: ======= --- - name: users_creation playbook   hosts: all   become: yes   tasks:      - name: create multiple users        user:           name: "{{item.name}}"           uid: "{{item.uid}}"           state: present       loop:           - name: 'kk1'             uid: '1001'           - name: 'kk2'              uid: '1002' 2nd model: ======== --- - name: users_creation playbook   hosts: all   become: yes   tasks:      - name: multiple users_creation        user:            name: "{{item.name}}"            uid: "{{item.uid}}"            state: present       loop:   ...

Write Ansible Playbook to install & configure webserver & copy index.html file using variables

 - name: httpd install playbook   hosts: all   become: yes   vars:     v1: httpd     v2: latest     v3: started     v4: restarted   tasks:     - name: Install httpd       yum:           name: "{{v1}}"           state: "{{v2}}"     - name: Start httpd service       service:          name: "{{v1}}"          state: "{{v3}}"     - name: copy index.html file            copy:                src: index.html                dest: /var/www/html     - name: restart httpd service       service:          name: "{{v1}}"          state: "{{v4}}"