Infrastructure as code: author Packer image builds and Ansible playbooks, graded structurally.
- Declare Packer input variableseasy · in-browser
Write /home/player/variables.pkr.hcl declaring two input variables: "region" (type string, default "us-east-2") and "instance_type" (type string, default "t3.micro").
(Authored config, graded structurally — the engine isn't run here.)
- Install a package & enable a service (Ansible)easy · in-browser
Write /home/player/nginx.yml: a play (hosts: webservers, become: true) that installs nginx with the package module and ensures the service is state: started and enabled: true.
(Authored config, graded structurally — the engine isn't run here.)
- Pin a Packer plugin (required_plugins)easy · in-browser
Write /home/player/build.pkr.hcl with the top-level packer {} block that pins the amazon plugin: a required_plugins block declaring amazon with source "github.com/hashicorp/amazon" and a version constraint.
(Authored config, graded structurally — the engine isn't run here.)
- Write a minimal Ansible playeasy · in-browser
Write /home/player/site.yml: one play targeting hosts: webservers, with become: true and a tasks: list containing an ansible.builtin.ping task.
(Authored config, graded structurally — the engine isn't run here.)
- Write an Ansible INI inventoryeasy · in-browser
Write /home/player/inventory.ini: a [web] group with two hosts that each set ansible_host, and a [web:vars] section setting ansible_user=ec2-user.
(Authored config, graded structurally — the engine isn't run here.)
- Add a Packer build with a shell provisionermedium · in-browser
Write /home/player/build.pkr.hcl with a build {} block that uses source.amazon-ebs.al2023 and runs a provisioner "shell" with an inline command list installing nginx.
(Authored config, graded structurally — the engine isn't run here.)
- Define an amazon-ebs Packer sourcemedium · in-browser
Write /home/player/build.pkr.hcl declaring source "amazon-ebs" "al2023" with region us-east-2, instance_type t3.micro, ssh_username ec2-user, and an ami_name.
(Authored config, graded structurally — the engine isn't run here.)
- Template a config & notify a handler (Ansible)medium · in-browser
Write /home/player/web.yml: a play that deploys a config with the template module to dest /etc/nginx/conf.d/app.conf, notifies a handler, and defines a handlers: section that restarts nginx (state: restarted).
(Authored config, graded structurally — the engine isn't run here.)
- Build & tag a Docker image with Packerpro · in-browser
Write /home/player/docker.pkr.hcl: source "docker" "alpine" with image "alpine:3.20" and commit = true; a build using it with a shell provisioner; and a post-processor "docker-tag" with a repository.
(Authored config, graded structurally — the engine isn't run here.)
- Create users with a loop (Ansible)pro · in-browser
Write /home/player/users.yml: a play that creates accounts with the user module, taking each name from {{ item }} over a loop, adding them to the wheel group.
(Authored config, graded structurally — the engine isn't run here.)