Ansible Assignment– 1

Ansible Core Concepts

Basic Questions

  1. Install Ansible on a Linux system using the package manager.
  2. Install Ansible on Windows using WSL (Windows Subsystem for Linux).
  3. Run Ansible inside a Docker container.
  4. Verify Ansible installation by checking the version.
  5. Create a new inventory file named hosts with one managed node.
  6. Add two servers with their IP addresses in the inventory file.
  7. Use an ad-hoc command to ping a managed node.
  8. Use an ad-hoc command to check the uptime of a managed node.
  9. Use an ad-hoc command to get the disk space of a managed node.
  10. Use an ad-hoc command to list all users on a managed node.
  11. Use an ad-hoc command to install a package (e.g., htop) on a managed node.
  12. Use an ad-hoc command to restart the SSH service on a managed node.
  13. Run your first Ansible ad-hoc command that prints “Hello Ansible”.
  14. Create a basic Ansible configuration file ansible.cfg.
  15. Add default inventory path in ansible.cfg.
  16. Display all facts about a managed node using an ad-hoc command.
  17. Print the hostname of a managed node using facts.
  18. Print the IP address of a managed node using facts.
  19. Create a simple YAML file and validate its syntax.
  20. Write a YAML file with key-value pairs representing student details.

Intermediate Questions

  1. Create an inventory file with three groups: web, db, and app servers.
  2. Run an ad-hoc command to ping all servers in the web group.
  3. Run an ad-hoc command to check free memory on all servers.
  4. Use an ad-hoc command to create a new directory on all managed nodes.
  5. Use an ad-hoc command to copy a file from control node to managed nodes.
  6. Use an ad-hoc command to delete a file on all managed nodes.
  7. Add variables in the inventory file for different groups.
  8. Print group variables using an ad-hoc command.
  9. Display system facts only related to network interfaces.
  10. Display system facts only related to CPU.
  11. Configure passwordless SSH between control node and managed nodes.
  12. Test SSH connectivity from control node to managed nodes.
  13. Create a YAML file to define a list of users.
  14. Create a YAML file to define a dictionary of server details.
  15. Write a YAML file with multiple documents separated by —.
  16. Use an ad-hoc command to check the current date and time on all servers.
  17. Use an ad-hoc command to check running processes on all servers.
  18. Create a new Ansible configuration file with custom log path.
  19. Set a default remote user in ansible.cfg.
  20. Use an ad-hoc command to reboot all managed nodes.

Advanced Questions

  1. Create an inventory with dynamic host groups for multiple environments (dev, test, prod).
  2. Use an ad-hoc command to install Apache on web servers and verify service status.
  3. Use an ad-hoc command to install MySQL on db servers and verify service status.
  4. Create an inventory file that defines variables for each host individually.
  5. Use an ad-hoc command to apply different package versions on different groups.
  6. Write a YAML file to define nested variables and validate its syntax.
  7. Collect and display only custom facts (hostname, memory, and disk) from all servers.
  8. Configure managed nodes to use SSH keys instead of passwords and test ad-hoc commands.
  9. Use an ad-hoc command to check connectivity for 5 servers at once and save results to a file.
  10. Create an end-to-end hands-on task: Install Ansible → Add 3 servers to inventory → Configure SSH → Run ad-hoc commands (ping, uptime, package install).