Monday, February 21, 2022

ASSIGNMENT: Ansible Ad-Hoc Commands by Raman 21.2.2022



Assignment:
Create a setup of 3 ubuntu Servers where one of the servers is the Master server where Ansible is installed whereas the other 2 webservers are managed nodes.

Perform the below tasks by using Ansible Adhoc commands:

1. Install Apache server on webservers using shell module
2. Stop Apache service on webservers using service module
3. Restart Apache service on webservers using service module.
4. Uninstall Apache service using apt module
5. Run date command on webservers.
6. Create a file call app.java under /tmp/java folder
7. Add some content to app.java file.
8. Read app.java file using shell module.
9. Delete app.java file.
10. Install tree command using apt module.

Answer:
  1. ansible webservers -m shell -a "apt install apache2 -y"
  2. ansible webservers -m service -a "name=apache2 state=stopped"
  3. ansible webservers -m service -a "name=apache2 state=restarted"
  4. ansible webservers -m apt -a "name=apache2 state=absent purge=yes"
  5. ansible webservers -m shell -a "date"
  6. Answer for 6:
    1. ansible webservers -m shell -a "mkdir /tmp/java/"
    2. ansible webservers -m shell -a "touch /tmp/java/app.java"
  7. ansible webservers -m copy -a "content='Hello World' dest=/tmp/java/app.java"
  8. ansible webservers -m shell -a "cat /tmp/java/app.java"
  9. ansible webservers -m shell -a "rm -ifr /tmp/java/app.java"
  10. ansible webservers -m apt -a "name=tree state=present"

No comments:

Post a Comment

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...