Ansible Assignment– 5
Advanced Ansible Features
Basic Questions
- Create a simple static inventory file and run a Playbook.
- Configure a dynamic inventory for AWS using aws_ec2 plugin.
- Configure a dynamic inventory for GCP using gcp_compute plugin.
- Configure a dynamic inventory for Azure using azure_rm plugin.
- Configure a dynamic inventory for Docker containers.
- Configure a dynamic inventory for Kubernetes pods.
- Install Ansible Vault and check the version.
- Encrypt a simple text file using Ansible Vault.
- Decrypt the file using Ansible Vault.
- Create an encrypted variable file with Ansible Vault.
- Use a Vault-encrypted variable inside a Playbook.
- Write a Playbook that prints a secret stored in Vault.
- Run a Playbook with the –ask-vault-pass option.
- Run a Playbook with a Vault password file.
- Create a Playbook with error handling using ignore_errors.
- Create a Playbook with error handling using failed_when.
- Run a Playbook in debug mode using -vvv flag.
- Use the debug module to print variable values.
- Run a Playbook with 10 forks for parallel execution.
- Change the default number of forks in ansible.cfg.
Intermediate Questions
- Configure a dynamic inventory that fetches EC2 instances by tag.
- Configure a dynamic inventory that fetches only running GCP instances.
- Configure a dynamic inventory that fetches only active Azure VMs.
- Configure a dynamic inventory for all running Docker containers.
- Configure a dynamic inventory that lists Kubernetes services.
- Write a Playbook that stores database credentials in Vault and retrieves them.
- Encrypt an entire Playbook using Ansible Vault and run it.
- Split sensitive variables into a separate file and encrypt it with Vault.
- Create a Playbook with a block that includes rescue and always sections.
- Write a Playbook that uses any_errors_fatal to stop execution on failure.
- Use the max_fail_percentage strategy in a Playbook.
- Run a Playbook with the free strategy.
- Run a Playbook with the serial strategy and set batch size to 2.
- Compare execution results between linear and free strategies.
- Add retries for a task using until with retries and delay.
- Create a Playbook that runs tasks on multiple hosts in parallel.
- Optimize Playbook execution using async and poll.
- Run a Playbook that prints hostnames of all dynamic inventory nodes.
- Use Vault to encrypt SSH keys for managed nodes.
- Create a Playbook that runs tasks on a different host using delegate_to.
Advanced Questions
- Configure a multi-cloud dynamic inventory using AWS, Azure, and GCP together.
- Create a dynamic inventory script in Python to fetch hosts from a custom API.
- Create a Vault-encrypted file with multiple secrets (DB password, API keys).
- Write a Playbook that decrypts secrets and uses them in multiple roles.
- Implement error handling in a Playbook with blocks, rescue, and always for a failed package installation.
- Create a Playbook that runs with serial: 1 strategy to deploy updates gradually.
- Write a Playbook that uses strategy: free for parallel execution across multiple hosts.
- Tune Ansible performance by modifying forks, pipelining, and SSH settings in ansible.cfg.
- Combine Vault and dynamic inventory: Encrypt cloud credentials and use them in a dynamic inventory Playbook.
- Build a complete pipeline: Use dynamic inventory → Encrypt secrets with Vault → Run Playbook with blocks → Apply strategy → Optimize performance.