[ norboten ]
ansible · lab ansible-02

The Deploy That Waits for a Password

· about 40 minutes · runs on ubuntu-26.04-devops · unrated

An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.

The briefing

deploy.service runs the playbook in /srv/deploy at every boot, as the deploy account. It renders the application's database settings into /srv/app/config/db.conf. The database password lives in the Ansible Vault file group_vars/app/vault.yml.

Since last week, the application starts with no database settings: the service fails at every boot. Someone "fixed" it by hand on another machine and ran the playbook from their own terminal, where Ansible asked them for the vault password. While debugging they also saved a decrypted copy of the vault file next to it, to read it.

The vault password is in /root/vault-password.txt. Keep using it.

What is expected, and graded:

  1. deploy.service succeeds at boot, with nobody logged in, and /srv/app/config/db.conf holds the password from the vault.
  2. Nothing under /srv/deploy contains the database password in plain text.
  3. The deploy reads the vault password from a file that only the deploy account can read.
  4. The deploy's own log does not contain the password.

You have root through sudo. Everything must still hold after a reboot.

What is graded

The machine is checked, rebooted, and checked again. A check passes only if it passes both times.

CheckObjective
01_deploy_runs_unattendedRun a playbook that uses Ansible Vault without a person at the keyboard
02_secrets_encrypted_at_restKeep secrets encrypted at rest and the vault password readable only by the account that needs it
03_vault_password_file_protectedKeep secrets encrypted at rest and the vault password readable only by the account that needs it
04_no_secret_in_the_logKeep secrets out of logs

Start it

  1. 2Labs
  2. ansible-02select this one
  3. udownload it
  4. sstart the machine

Reading

Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).

Theory for this lab

4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:

Question 1

A playbook run from a systemd service fails with `EOFError (ctrl-d) on prompt`. Which `ansible.cfg` setting is the likely cause?

Question 2

A file named by `vault_password_file` has mode 0755. What does Ansible do with it?

Question 3

Which files in `group_vars/app/` does Ansible load as variables?