4.1 KiB
Lessons Learned
-
The
networkrole in this repository is a powerful tool that sets up a complete network stack, including Nginx Proxy Manager for reverse proxying andwireguard-easyfor a WireGuard web UI. -
The
giteaandpostgresroles use Docker Compose to deploy their respective services. -
Properly managing variables, especially secrets like passwords and API keys, is crucial. Using
group_varsand a.gitignoredsecretsdirectory is a good practice. -
It's important to have a clear plan and get user feedback before making any changes. The "planning mode" and "acting mode" paradigm is a good way to structure the workflow.
-
The
dockerrole proved problematic on Ubuntu 24.04 (noble) due to repository issues. -
Podman is a viable and simpler alternative to Docker for container management.
-
Ansible modules designed for Docker (e.g.,
community.docker.docker_compose_v2,docker_container) are not directly compatible with Podman. -
podman-composecan be used withansible.builtin.shellfor managingdocker-compose.ymlfiles with Podman. -
containers.podman.podman_containeris the direct replacement fordocker_containerfor managing individual Podman containers. -
Ansible Vault is crucial for securely managing sensitive data like passwords in version control.
-
General Debugging Principles:
- Always trust the user's direct experience and observations, even if they initially contradict assumptions or playbook output.
- When a playbook reports success but the desired state isn't met, investigate deeper. Ansible's
changedstatus can be misleading if the underlying application fails after the module reports success. - Use increased verbosity (
-vvv) for detailed debugging output from Ansible. - Systematically verify each layer of the stack (container logs, host processes, host firewall, cloud firewall).
-
Podman Specifics & Rootless Containers:
- Rootless Podman requires tasks managing user-specific files and containers to explicitly use
become: false. - Using
~(tilde) in paths for user home directories is more robust than relying onansible_user_dir, which can sometimes resolve unexpectedly. - Fully qualifying image names (e.g.,
docker.io/portainer/portainer-ce) prevents registry ambiguity issues and avoids interactive prompts. - Debugging container startup issues requires checking:
podman ps -a(to see all containers, running or exited).podman logs <container_name>(to get application logs).sudo podman ps(to check for rootful containers that might be interfering).
- Orphaned
conmonprocesses from failed container startups can block ports and require manual cleanup (sudo kill <PID>,podman stop/rm). - Ensure
registries.confis correctly templated (ansible.builtin.template, notansible.builtin.copy) and placed in~/.config/containers/registries.conffor rootless Podman. - Verify Podman's actual listening port on the host with
sudo ss -tulnp | grep <port>(orlsof).
- Rootless Podman requires tasks managing user-specific files and containers to explicitly use
-
Ansible Best Practices:
- Idempotency is paramount: Always strive for idempotent tasks that describe the desired state (e.g.,
ansible.posix.firewalld,ansible.builtin.service) rather than imperative shell commands. - Ensure all necessary Python libraries (
python3-firewall) and system services (firewalld) are installed and running on target hosts before modules that depend on them are called. - Explicitly set
become: falseon tasks that should run as the connecting user, especially when the play hasbecome: trueby default. - The
ansible.builtin.templatemodule must be used for Jinja2 templates;ansible.builtin.copydoes not process templates.
- Idempotency is paramount: Always strive for idempotent tasks that describe the desired state (e.g.,
-
Networking & Cloud Considerations:
- Host firewall (
firewalld) rules are separate from cloud provider security rules (e.g., Oracle Cloud Network Security Groups/Security Lists). Both layers must be correctly configured. - Ansible playbooks typically cannot manage cloud provider firewalls without specific cloud collections (e.g.,
oracle.oci).
- Host firewall (