Selfnote of ANSIBLE PLAYBOOK –

DevOps

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare
  • Write a Ansible Playbook to create a group called “deploy” :
$ ansible Create a group name=deploy state=present

- name: Deploy
  hosts: webservers

  tasks:
  - name: create a group
    group:
      name: deploy
      state: present
 
  • Write a Ansible Playbook to create a user called “deploy-user” which is part of group called “deploy” and with /bin/bash shell :
$ ansible name=deploy-user group=deploy shell=/bin/bash state=present

- name: Deploy
  hosts: webservers

  tasks:
  - name: create user
    user:
      name: deploy-user

      shell:/bin/bash
      group: deployCode language: JavaScript (javascript)
  • Write a Ansible Playbook to install package named “httpd” in RHEL/centos :
$ install Apache name=httpd

- name: Start Installing Package
  hosts: webservers

  tasks:
  - name: install package
    yum:
      name: httpd

      state: present
  • Write a Ansible Playbook to start and enable the service named “httpd” :
$ ansible localhost -m service -a"name=httpd state=started"

- name: Starting the service
  hosts: webservers

  tasks:
  - name: start service
    service:
      name: httpd

      state: startedCode language: JavaScript (javascript)
  • Write a Ansible Playbook to create a file called “index.html” in /var/www/html with some dummy html contents :
$ ansible Create a file dest=/var/www/html/index.html mode=600 state=touch

- name: Initiating File Creation
  hosts: webservers

  tasks:
  - name: creating a file
    copy:
      src: index.html

      dest: /var/www/html/index.htmlCode language: JavaScript (javascript)
  • Write a Ansible Playbook to reboot a self machine :
$ ansible all -m ansible.builtin.reboot -a"name=reboot the machine"


- name: Started reboot
  hosts: webservers

  tasks:
  - name: rebooting the machine
    reboot:
      name: reboot the machine
      msg: rebooting the machineCode language: JavaScript (javascript)
  • Write a Ansible Playbook to install a package called “git”, “wget” :
$ ansible Install git, wget packages name=git,wget state=present