Debug School

Sravya
Sravya

Posted on

Ansible assignment day2

1.


  • name: Write a Ansible Playbook to create a group called “deploy” hosts: web

tasks:
- name: create group
ansible.builtin.group:
name: deploy
state: present

2.

  • name: Write a Ansible Playbook to create a user called “deploy-user” which is part of group called “deploy” and with /bin/bash shell hosts: web

tasks:
- name: create user
ansible.builtin.user:
state: present
name: deploy-user
group: deploy
shell: /bin/bash

3.

  • name: Write a Ansible Playbook to install package named “httpd” in RHEL/centos. hosts: web

tasks:
- name: Install the latest version of Apache
ansible.builtin.yum:
name: httpd
state: absent
- name: Install the latest version of Apache
ansible.builtin.yum:
name: httpd
state: latest

4.

  • name: Write a Ansible Playbook to start and enable the service named “httpd” hosts: web

tasks:
- name: Start service httpd, if not started
ansible.builtin.service:
name: httpd
state: started
- name: Start service httpd, if not started
ansible.builtin.service:
name: firewalld
state: stopped
enabled: no

5.


  • name: Write a Ansible Playbook to create a file called “index.html” in /var/www/html with some dummy html contents. hosts: web

tasks:
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html

6.

  • name: Write a Ansible Playbook to reboot a self machine hosts: web

tasks:
- name: reboot
ansible.builtin.reboot:

7.


  • name: Write a Ansible Playbook to install a package called “git”, “wget” hosts: web

tasks:
-name: Install package git
ansible.builtin.yum:
state: present
name: git

tasks:
-name: Install package wget
ansible.builtin.yum:
state: present
name: wget

8.

tasks:
-name: Clone repo
ansible.builtin.git:
repo: https://github.com/scmgalaxy/ansible-role-template
dest: /root/ansible/test
clone: yes

Top comments (0)