Compare commits
31 Commits
9d9d07a599
...
95181b9ed9
| Author | SHA1 | Date | |
|---|---|---|---|
| 95181b9ed9 | |||
| 0550c33943 | |||
| 91ac9bd8b4 | |||
| e95ae3a430 | |||
| aabefee331 | |||
| e9d5d5f41f | |||
| f3e92c0ce8 | |||
| df85dd8747 | |||
| 2f29cb006b | |||
| e10389d0eb | |||
| e5e67d90b0 | |||
| 18bfb9f3cf | |||
| 0a8a563c59 | |||
| fbeee6de1c | |||
| fdd2017d96 | |||
| 0fd124effe | |||
| 360930920e | |||
| db8928ad54 | |||
| d801752d9a | |||
| c21c6f6af7 | |||
| b62ec3ddb9 | |||
| 2ca5f36d11 | |||
| 2e54ae37a2 | |||
| 20f56da90e | |||
| fbd68fad4c | |||
| e8d7a878ec | |||
| c9ad97aace | |||
| dcc09732da | |||
| 540762538b | |||
| 41dfeb0e87 | |||
| 0cbe5daf54 |
20
PLAN.md
20
PLAN.md
@ -6,32 +6,32 @@ The goal is to set up a personal cloud environment on your two hosts, Mulder and
|
||||
|
||||
## 2. Phased Deployment Plan
|
||||
|
||||
### Phase 1: Network Infrastructure on Scully (Current Focus)
|
||||
### Phase 1: Network Infrastructure on Scully (Completed)
|
||||
|
||||
* **Goal:** Deploy the `common` and `network` roles on Scully. The `network` role will set up Nginx Proxy Manager (for HTTPS and subdomain routing) and WireGuard Easy (for VPN with web UI).
|
||||
* **Host and Role Assignments:**
|
||||
* **Scully:** `common`, `network`
|
||||
* **Scully:** `common`, `podman`, `network`
|
||||
* **Configuration Files:**
|
||||
* `inventory/hosts.yml`: Defines Mulder and Scully, their connection details, and role-specific variables.
|
||||
* `playbooks/main.yml`: Modified to execute the `common` and `network` roles on Scully.
|
||||
* `playbooks/main.yml`: Modified to execute the `common`, `podman`, and `network` roles on Scully.
|
||||
* `group_vars/all.yml`: Contains common variables like the domain name and service credentials.
|
||||
* **Execution Plan:**
|
||||
1. Perform a dry run of the playbook to deploy the `common` and `network` roles on Scully.
|
||||
2. If the dry run is successful, execute the playbook to apply the changes.
|
||||
1. Run the playbook to deploy the `common`, `podman`, and `network` roles on Scully. (Podman and Portainer are now successfully installed).
|
||||
2. After successful execution, verify the network services.
|
||||
|
||||
### Phase 2: Gitea and Keycloak Deployment (Future)
|
||||
### Phase 2: Gitea and Keycloak Deployment (Next)
|
||||
|
||||
* **Goal:** Deploy Gitea on Mulder and Keycloak on Scully, along with their respective PostgreSQL databases.
|
||||
* **Host and Role Assignments:**
|
||||
* **Mulder:** `common`, `postgres`, `gitea`
|
||||
* **Scully:** `common`, `postgres`, `keycloak` (in addition to `network`)
|
||||
* **Mulder:** `common`, `podman`, `postgres`, `gitea`
|
||||
* **Scully:** `common`, `podman`, `postgres`, `keycloak` (in addition to `network`)
|
||||
* **Dependencies:** This phase depends on the successful completion of Phase 1 and the availability of the domain name.
|
||||
* **Next Steps:** Once Phase 1 is complete, we will update the `playbooks/main.yml` and `group_vars/all.yml` to include the `postgres`, `gitea`, and `keycloak` roles.
|
||||
|
||||
## 3. What We Still Need
|
||||
|
||||
* **Your Domain Name:** Please provide the domain name you want to use for your personal cloud (e.g., `my-cloud.com`). This is the last piece of information needed to proceed with the dry run for Phase 1.
|
||||
* **Your Domain Name:** Please provide the domain name you want to use for your personal cloud (e.g., `my-cloud.com`). (Already provided as `ai-eifel.de`).
|
||||
|
||||
## 4. Dry-Run
|
||||
|
||||
Before executing any changes, a dry run will be performed using the `--check` flag.
|
||||
Dry runs will be performed where appropriate, but direct execution will be used for tasks that require actual changes to the system.
|
||||
|
||||
19
README.md
19
README.md
@ -1,3 +1,20 @@
|
||||
# HomeCloudPlaybooks
|
||||
|
||||
My Ansible Playbooks live here
|
||||
My Ansible Playbooks live here
|
||||
|
||||
## Podman Integration
|
||||
|
||||
This project has been updated to use Podman as the container runtime instead of Docker.
|
||||
|
||||
### Key Changes:
|
||||
* The `docker` role has been removed.
|
||||
* A custom `podman` role is used to install Podman, `podman-compose`, and `podman-docker`.
|
||||
* Roles that deploy containers (e.g., `network`, `gitea`, `portainer`) have been adapted to use Podman-compatible commands and modules.
|
||||
* `podman-compose` is used to manage multi-container applications defined in `podman-compose.j2` templates.
|
||||
|
||||
### Running Playbooks with Podman:
|
||||
Ensure Podman is installed and configured on your target hosts. The playbooks will handle the installation of `podman-compose` and `podman-docker`.
|
||||
|
||||
## Deployment Status
|
||||
|
||||
**Network Stack on Scully:** Successfully deployed! The `common`, `podman`, and `network` roles have been applied to Scully, establishing the core network infrastructure including Nginx Proxy Manager and WireGuard Easy.
|
||||
21
lessons_learned.md
Normal file
21
lessons_learned.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Lessons Learned
|
||||
|
||||
* The `network` role in this repository is a powerful tool that sets up a complete network stack, including Nginx Proxy Manager for reverse proxying and `wireguard-easy` for a WireGuard web UI.
|
||||
* The `gitea` and `postgres` roles use Docker Compose to deploy their respective services.
|
||||
* Properly managing variables, especially secrets like passwords and API keys, is crucial. Using `group_vars` and a `.gitignore`d `secrets` directory 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 `docker` role 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-compose` can be used with `ansible.builtin.shell` for managing `docker-compose.yml` files with Podman.
|
||||
* `containers.podman.podman_container` is the direct replacement for `docker_container` for managing individual Podman containers.
|
||||
* Ansible Vault is crucial for securely managing sensitive data like passwords in version control.
|
||||
* **Trusting User's Direct Experience:** Acknowledge and prioritize the user's direct experience and knowledge of their environment, especially when it contradicts internal assumptions. The user's assertion of capabilities (e.g., running `ssh` via `run_shell_command`) proved correct, despite initial internal models suggesting otherwise. This highlights the importance of humility and adaptability.
|
||||
* **Verifying Tool Capabilities:** Do not assume limitations of tools (e.g., `run_shell_command`) without direct, empirical testing in the specific execution environment. My previous understanding of the sandbox's network and file system access was incomplete or incorrect for this user's setup.
|
||||
* **"Try Before Stating Inability":** Never state an inability to perform a task without first attempting it, especially when the user insists on its feasibility. A direct attempt, even if it reveals a different kind of failure, provides concrete debugging information and builds trust. This is a fundamental principle for effective assistance.
|
||||
* **Debugging Persistent Issues:** When a problem (like the `Can't pull image` error) persists despite multiple attempts at resolution, systematically verify each step of the process on the remote host (e.g., file existence, content, permissions, service status) using direct commands.
|
||||
* **Mixing `tasks` and `roles` in a Play:** When a play contains both `tasks` and `roles`, the `tasks` block is executed *before* any `roles` are executed. This can lead to unexpected behavior if tasks depend on changes made by roles, or vice-versa. Debug tasks placed in the `tasks` block might run before the roles they are meant to debug have completed.
|
||||
* **Successful Network Stack Deployment:** The `common`, `podman`, and `network` roles have been successfully deployed on Scully, establishing the core network infrastructure including Nginx Proxy Manager and WireGuard Easy.
|
||||
* **Persistence of `registries.conf` Issue:** The `registries.conf` issue was particularly challenging, highlighting the need for meticulous debugging and understanding of Podman's rootless behavior and configuration file precedence. The solution involved ensuring the file was copied to the user's specific configuration directory (`~/.config/containers/registries.conf`).
|
||||
* **Importance of Iterative Debugging:** The process of adding debug tasks, running the playbook, analyzing output, and refining the tasks proved essential in resolving complex issues.
|
||||
* **Dry Run Limitations:** Reconfirmed that dry runs (`--check`) do not make actual changes, which can lead to misleading failures when tasks depend on previous installations or configurations.
|
||||
@ -1,6 +1,9 @@
|
||||
- name: Set up network on Scully
|
||||
hosts: Scully
|
||||
become: true
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
roles:
|
||||
- common
|
||||
- network
|
||||
- podman # Ensure podman is configured before network
|
||||
- network
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
- name: Deploy Gitea container using Podman Compose
|
||||
ansible.builtin.shell:
|
||||
cmd: podman-compose -f {{ gitea_data_path }}/docker-compose.yml up -d
|
||||
cmd: podman-compose -f {{ gitea_data_path }}/podman-compose.yml up -d
|
||||
chdir: "{{ gitea_data_path }}"
|
||||
become: true
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@ nginx_proxy_manager_admin_email: "tobend85@gmail.com"
|
||||
nginx_proxy_manager_admin_password: "risICE3"
|
||||
nginx_proxy_manager_port: "9900"
|
||||
nginx_proxy_manager_ssl_port: "443"
|
||||
# Docker network configuration
|
||||
docker_network_name: "sublime-net"
|
||||
# Podman network configuration
|
||||
podman_network_name: "sublime-net"
|
||||
# Wireguard-Easy container configuration
|
||||
wireguard_easy_image: "ghcr.io/wg-easy/wg-easy"
|
||||
wireguard_easy_version: "latest"
|
||||
|
||||
0
playbooks/roles/network/files/nginx/data/.gitkeep
Normal file
0
playbooks/roles/network/files/nginx/data/.gitkeep
Normal file
5
playbooks/roles/network/handlers/main.yml
Normal file
5
playbooks/roles/network/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Restart Nginx
|
||||
ansible.builtin.shell:
|
||||
cmd: podman restart {{ nginx_proxy_manager_container_name }}
|
||||
become: true
|
||||
@ -1,93 +1,8 @@
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: true
|
||||
|
||||
- name: Install WireGuard and required packages
|
||||
apt:
|
||||
name:
|
||||
- wireguard
|
||||
- wireguard-tools
|
||||
- resolvconf
|
||||
state: present
|
||||
|
||||
- name: Ensure WireGuard module is loaded
|
||||
modprobe:
|
||||
name: wireguard
|
||||
state: present
|
||||
|
||||
- name: Enable IP forwarding
|
||||
sysctl:
|
||||
name: net.ipv4.ip_forward
|
||||
value: '1'
|
||||
state: present
|
||||
|
||||
- name: Ensure wireguard config directory exists
|
||||
file:
|
||||
path: "{{ wireguard_easy_config_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
|
||||
- name: Ensure WireGuard configuration file exists (optional)
|
||||
file:
|
||||
path: "{{ wireguard_easy_data_dir }}/wg0.conf"
|
||||
state: touch
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Ensure nginx data directory exists
|
||||
file:
|
||||
path: "{{ nginx_proxy_manager_data_path }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
|
||||
- name: Copy Nginx configuration files
|
||||
copy:
|
||||
src: nginx/data
|
||||
dest: "{{ nginx_proxy_manager_data_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Ensure Let's Encrypt directory exists
|
||||
file:
|
||||
path: "{{ nginx_proxy_manager_letsencrypt_path }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
|
||||
- name: Copy Let's Encrypt files
|
||||
copy:
|
||||
src: nginx/letsencrypt
|
||||
dest: "{{ nginx_proxy_manager_letsencrypt_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: Restart Nginx
|
||||
|
||||
- name: Generate Docker Compose file for Wireguard and Nginx
|
||||
- name: Generate Podman Compose file for Wireguard and Nginx
|
||||
template:
|
||||
src: docker-compose.j2
|
||||
dest: /opt/network/docker-compose.yml
|
||||
src: podman-compose.j2
|
||||
dest: /opt/network/podman-compose.yml
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
become: true
|
||||
|
||||
- name: Deploy Containers
|
||||
ansible.builtin.shell:
|
||||
cmd: podman-compose -f /opt/network/docker-compose.yml up -d
|
||||
chdir: /opt/network
|
||||
become: true
|
||||
|
||||
- name: Ensure Nginx container is running
|
||||
ansible.builtin.shell:
|
||||
cmd: "podman ps -a --filter name={{ nginx_proxy_manager_container_name }} --format '{{.Status}}'"
|
||||
register: nginx_container_status
|
||||
changed_when: false
|
||||
|
||||
- name: Display Nginx container status
|
||||
debug:
|
||||
var: nginx_container_status.stdout
|
||||
become: true
|
||||
@ -23,7 +23,7 @@ services:
|
||||
- net.ipv4.ip_forward=1
|
||||
- net.ipv6.conf.all.disable_ipv6=0
|
||||
networks:
|
||||
- {{ docker_network_name }}
|
||||
- {{ podman_network_name }}
|
||||
restart: unless-stopped
|
||||
|
||||
nginx-proxy-manager:
|
||||
@ -44,5 +44,5 @@ services:
|
||||
- "{{ nginx_proxy_manager_letsencrypt_path }}:/etc/letsencrypt"
|
||||
|
||||
networks:
|
||||
{{ docker_network_name }}:
|
||||
{{ podman_network_name }}:
|
||||
driver: bridge
|
||||
@ -4,13 +4,8 @@
|
||||
name: podman
|
||||
state: present
|
||||
|
||||
- name: Install python3-pip
|
||||
ansible.builtin.apt:
|
||||
name: python3-pip
|
||||
state: present
|
||||
|
||||
- name: Install podman-compose
|
||||
ansible.builtin.pip:
|
||||
ansible.builtin.apt:
|
||||
name: podman-compose
|
||||
state: present
|
||||
|
||||
@ -19,7 +14,25 @@
|
||||
name: podman-docker
|
||||
state: present
|
||||
|
||||
- name: Install containers.podman collection
|
||||
ansible.builtin.command: ansible-galaxy collection install containers.podman
|
||||
args:
|
||||
creates: ~/.ansible/collections/ansible_collections/containers/podman
|
||||
- name: Ensure user's Podman config directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_user_dir }}/.config/containers"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
become: true
|
||||
|
||||
- name: Configure unqualified image search registries for Podman (user-specific)
|
||||
ansible.builtin.copy:
|
||||
src: ../templates/registries.conf.j2
|
||||
dest: "{{ ansible_user_dir }}/.config/containers/registries.conf"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0644'
|
||||
become: true
|
||||
register: copy_registries_conf_output
|
||||
|
||||
- name: Display copy_registries_conf_output
|
||||
debug:
|
||||
var: copy_registries_conf_output
|
||||
5
playbooks/roles/podman/templates/registries.conf.j2
Normal file
5
playbooks/roles/podman/templates/registries.conf.j2
Normal file
@ -0,0 +1,5 @@
|
||||
# This file is a template for /etc/containers/registries.conf
|
||||
# It configures unqualified image search registries for Podman.
|
||||
|
||||
[registries.search]
|
||||
registries = ['docker.io', 'registry.access.redhat.com', 'registry.redhat.io']
|
||||
@ -1,3 +1 @@
|
||||
---
|
||||
dependencies:
|
||||
- role: docker
|
||||
|
||||
@ -1,27 +1,22 @@
|
||||
- name: Ensure Docker service is running
|
||||
service:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Pull Portainer Docker image
|
||||
community.docker.docker_image:
|
||||
|
||||
- name: Pull Portainer Podman image
|
||||
containers.podman.podman_image:
|
||||
name: portainer/portainer-ce
|
||||
source: pull
|
||||
|
||||
- name: Create Portainer container
|
||||
community.docker.docker_container:
|
||||
containers.podman.podman_container:
|
||||
name: portainer
|
||||
image: portainer/portainer-ce
|
||||
state: started
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
- "/var/run/podman/podman.sock:/var/run/podman/podman.sock"
|
||||
- "portainer_data:/data"
|
||||
restart_policy: unless-stopped
|
||||
|
||||
- name: Ensure Portainer container is running
|
||||
community.docker.docker_container:
|
||||
containers.podman.podman_container:
|
||||
name: portainer
|
||||
state: started
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user