Question 1
- name: Create Deploy group
hosts: web
tasks:
- name: create delpy group
group:
name: deploy
state: present
ansible-playbook -i inventory group.yaml -u root -k
Question2
- name: Create user in deploy group
hosts: web
tasks:
- name: create deploy-user in deploy group
user:
name: deploy-user
shell: /bin/bash
groups: deploy
append: yes
ansible-playbook -i inventory user.yaml -u root -k
Question3
- name: Install apache
hosts: web
tasks:
- name: Install Apache
yum:
name: httpd
state: latest
ansible-playbook -i inventory apache.yaml -u root -k
Question4
- name: Start apache
hosts: web
tasks:
- name: Start Apache service
service:
name: httpd
state: started
enabled: yes
ansible-playbook -i inventory apachestart.yaml -u root -k
Question5
- name: create html file with dummy code
hosts: web
tasks:
- name: copy command to create html file with dummy code
copy:
dest: /var/www/html/index.html
content: <!DOCTYPE html>My web page
Hello, world!
ansible-playbook -i inventory samplehtml.yaml -u root -k
Question6
- name: reboot machine
hosts: web
tasks:
- name: reboot machine
reboot:
ansible-playbook -i inventory reboot.yaml -u root -k
Question7
- name: Install Git
hosts: localhost
tasks:
- name: Install Git
yum:
name: git
ansible-playbook -i inventory git.yaml -u root -k
Top comments (0)