Ansible Assignment– 1
Ansible Core Concepts
Basic Questions
- Install Ansible on a Linux system using the package manager.
- Install Ansible on Windows using WSL (Windows Subsystem for Linux).
- Run Ansible inside a Docker container.
- Verify Ansible installation by checking the version.
- Create a new inventory file named hosts with one managed node.
- Add two servers with their IP addresses in the inventory file.
- Use an ad-hoc command to ping a managed node.
- Use an ad-hoc command to check the uptime of a managed node.
- Use an ad-hoc command to get the disk space of a managed node.
- Use an ad-hoc command to list all users on a managed node.
- Use an ad-hoc command to install a package (e.g., htop) on a managed node.
- Use an ad-hoc command to restart the SSH service on a managed node.
- Run your first Ansible ad-hoc command that prints “Hello Ansible”.
- Create a basic Ansible configuration file ansible.cfg.
- Add default inventory path in ansible.cfg.
- Display all facts about a managed node using an ad-hoc command.
- Print the hostname of a managed node using facts.
- Print the IP address of a managed node using facts.
- Create a simple YAML file and validate its syntax.
- Write a YAML file with key-value pairs representing student details.
Intermediate Questions
- Create an inventory file with three groups: web, db, and app servers.
- Run an ad-hoc command to ping all servers in the web group.
- Run an ad-hoc command to check free memory on all servers.
- Use an ad-hoc command to create a new directory on all managed nodes.
- Use an ad-hoc command to copy a file from control node to managed nodes.
- Use an ad-hoc command to delete a file on all managed nodes.
- Add variables in the inventory file for different groups.
- Print group variables using an ad-hoc command.
- Display system facts only related to network interfaces.
- Display system facts only related to CPU.
- Configure passwordless SSH between control node and managed nodes.
- Test SSH connectivity from control node to managed nodes.
- Create a YAML file to define a list of users.
- Create a YAML file to define a dictionary of server details.
- Write a YAML file with multiple documents separated by —.
- Use an ad-hoc command to check the current date and time on all servers.
- Use an ad-hoc command to check running processes on all servers.
- Create a new Ansible configuration file with custom log path.
- Set a default remote user in ansible.cfg.
- Use an ad-hoc command to reboot all managed nodes.
Advanced Questions
- Create an inventory with dynamic host groups for multiple environments (dev, test, prod).
- Use an ad-hoc command to install Apache on web servers and verify service status.
- Use an ad-hoc command to install MySQL on db servers and verify service status.
- Create an inventory file that defines variables for each host individually.
- Use an ad-hoc command to apply different package versions on different groups.
- Write a YAML file to define nested variables and validate its syntax.
- Collect and display only custom facts (hostname, memory, and disk) from all servers.
- Configure managed nodes to use SSH keys instead of passwords and test ad-hoc commands.
- Use an ad-hoc command to check connectivity for 5 servers at once and save results to a file.
- 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).