Lab Manual
Lab Manual
FINAL PRESENTATION
Submitted By: Adnan Khurshid
Topic: Ansible manage host & Playbook
Arranged By: Mature Resource Global
Technologies
=> ansible all -m ping “result” this module always returns `pong' on successful contact.
=> ansible all --list-host “result” this module always returns all hosts information.
=> ansible all -m service -a “name=httpd state=started” To start httpd service on all hosts
=> ansible all -m service -a “name=httpd state=restarted” To restart httpd service on all
hosts
=> ansible all -m service -a “name=httpd state=stopped” To stop httpd service on all
hosts
=> ansible all -m setup To check all facts
TASK 2: To ensure a specific single line of text exists in an existing file, use the lineinfile
module:
---
- name:"task handler"
hosts: servera
tasks:
- name: "task1"
lineinfile:
path: /etc/ssh/sshd_config
line: port 22
notify:
- restart service
handlers:
- name: restart service
service:
name: sshd
state: restarted
…