Sign inSign up free

1256. The New Port Never Takes Effect

medium 20 XP ~10 minHands-on lab

The web servers web1 and web2 run a small service, shopapi (a systemd unit), that listens on the port set in /etc/shopapi/shopapi.env. The team changed the port to 9000 in /home/student/ansible/group_vars/web.yml and ran deploy.yml. The file on the hosts now says 9000, but shopapi still answers on 8080 only.

Task

Fix /home/student/ansible/deploy.yml (and run it) so that:

  1. shopapi on web1 and web2 answers on port 9000, and no longer on 8080.
  2. Whenever the playbook changes shopapi.env on a host, shopapi is restarted on that host, and only then: a run that changes nothing restarts nothing and reports changed=0.

Keep the port in group_vars/web.yml.

About this machine

Ubuntu 24.04 with no internet access and ansible-core installed. Three managed hosts sit next to it: web1, web2 and db1, separate machines with systemd and Python, reached over ssh as root. Only the ansible.builtin modules are available, and nothing can be downloaded. The grader runs your playbooks and checks the hosts' final state, not the commands you typed.

Part of Ansible from Zero. Next step: What Vault Protects

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.