Ansible Assignment– 5

Advanced Ansible Features

Basic Questions

  1. Create a simple static inventory file and run a Playbook.
  2. Configure a dynamic inventory for AWS using aws_ec2 plugin.
  3. Configure a dynamic inventory for GCP using gcp_compute plugin.
  4. Configure a dynamic inventory for Azure using azure_rm plugin.
  5. Configure a dynamic inventory for Docker containers.
  6. Configure a dynamic inventory for Kubernetes pods.
  7. Install Ansible Vault and check the version.
  8. Encrypt a simple text file using Ansible Vault.
  9. Decrypt the file using Ansible Vault.
  10. Create an encrypted variable file with Ansible Vault.
  11. Use a Vault-encrypted variable inside a Playbook.
  12. Write a Playbook that prints a secret stored in Vault.
  13. Run a Playbook with the –ask-vault-pass option.
  14. Run a Playbook with a Vault password file.
  15. Create a Playbook with error handling using ignore_errors.
  16. Create a Playbook with error handling using failed_when.
  17. Run a Playbook in debug mode using -vvv flag.
  18. Use the debug module to print variable values.
  19. Run a Playbook with 10 forks for parallel execution.
  20. Change the default number of forks in ansible.cfg.

Intermediate Questions

  1. Configure a dynamic inventory that fetches EC2 instances by tag.
  2. Configure a dynamic inventory that fetches only running GCP instances.
  3. Configure a dynamic inventory that fetches only active Azure VMs.
  4. Configure a dynamic inventory for all running Docker containers.
  5. Configure a dynamic inventory that lists Kubernetes services.
  6. Write a Playbook that stores database credentials in Vault and retrieves them.
  7. Encrypt an entire Playbook using Ansible Vault and run it.
  8. Split sensitive variables into a separate file and encrypt it with Vault.
  9. Create a Playbook with a block that includes rescue and always sections.
  10. Write a Playbook that uses any_errors_fatal to stop execution on failure.
  11. Use the max_fail_percentage strategy in a Playbook.
  12. Run a Playbook with the free strategy.
  13. Run a Playbook with the serial strategy and set batch size to 2.
  14. Compare execution results between linear and free strategies.
  15. Add retries for a task using until with retries and delay.
  16. Create a Playbook that runs tasks on multiple hosts in parallel.
  17. Optimize Playbook execution using async and poll.
  18. Run a Playbook that prints hostnames of all dynamic inventory nodes.
  19. Use Vault to encrypt SSH keys for managed nodes.
  20. Create a Playbook that runs tasks on a different host using delegate_to.

Advanced Questions

  1. Configure a multi-cloud dynamic inventory using AWS, Azure, and GCP together.
  2. Create a dynamic inventory script in Python to fetch hosts from a custom API.
  3. Create a Vault-encrypted file with multiple secrets (DB password, API keys).
  4. Write a Playbook that decrypts secrets and uses them in multiple roles.
  5. Implement error handling in a Playbook with blocks, rescue, and always for a failed package installation.
  6. Create a Playbook that runs with serial: 1 strategy to deploy updates gradually.
  7. Write a Playbook that uses strategy: free for parallel execution across multiple hosts.
  8. Tune Ansible performance by modifying forks, pipelining, and SSH settings in ansible.cfg.
  9. Combine Vault and dynamic inventory: Encrypt cloud credentials and use them in a dynamic inventory Playbook.
  10. Build a complete pipeline: Use dynamic inventory → Encrypt secrets with Vault → Run Playbook with blocks → Apply strategy → Optimize performance.