-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
257ef38
commit c556b36
Showing
5 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Portainer Installation 🚀 | ||
|
||
This repository contains Ansible playbooks for installing and cleaning up Portainer Community Edition (CE) and Business Edition (BE). These playbooks manage Docker containers and images. | ||
|
||
## 🛠 Installation Playbooks | ||
|
||
### 📥 `install_portainer_ce.yml` | ||
This playbook installs Portainer CE (Community Edition): | ||
- Creates a Docker volume. | ||
- Runs the Portainer container. | ||
- Displays the list of Docker containers. | ||
|
||
**Usage:** | ||
```bash | ||
ansible-playbook -i inventory install_portainer_ce.yml | ||
``` | ||
|
||
### 📥 `install_portainer_ee.yml` | ||
This playbook installs Portainer EE (Interprice Edition): | ||
- Creates a Docker volume. | ||
- Runs the Portainer container. | ||
- Displays the list of Docker containers. | ||
|
||
**Usage:** | ||
```bash | ||
ansible-playbook -i inventory install_portainer_ee.yml | ||
``` | ||
|
||
### 🧹 Cleanup Playbook | ||
🗑️ `clean_portainer.yml` | ||
This playbook cleans up Portainer CE and BE installations: | ||
|
||
* Removes the Portainer container (if it exists). | ||
* Removes the Docker volume (if it exists). | ||
* Removes Portainer CE and BE Docker images (if they exist). | ||
**Usage:** | ||
|
||
```bash | ||
ansible-playbook -i inventory clean_portainer.yml | ||
``` | ||
|
||
### 🔍 Notes | ||
* The playbooks check for the existence of containers, volumes, and images before attempting removal. | ||
* Docker images are checked using the **2.21.2** tag for Portainer CE and EE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- name: Clean up Portainer installation | ||
hosts: all | ||
become: yes | ||
|
||
tasks: | ||
- name: Check if Portainer container exists | ||
shell: docker ps -a --format '{{"{{.Names}}"}}' | grep -w portainer || true | ||
register: portainer_exists | ||
changed_when: false | ||
|
||
- name: Remove Portainer container | ||
command: docker rm -f portainer | ||
when: portainer_exists.stdout != "" | ||
ignore_errors: yes | ||
|
||
- name: Check if Portainer volume exists | ||
shell: docker volume ls --format '{{"{{.Name}}"}}' | grep -w portainer_data || true | ||
register: volume_exists | ||
changed_when: false | ||
|
||
- name: Remove Portainer Docker volume | ||
command: docker volume rm portainer_data | ||
when: volume_exists.stdout != "" | ||
ignore_errors: yes | ||
|
||
- name: Check if Portainer CE image exists | ||
shell: docker images --format '{{"{{.Repository}}:{{.Tag}}"}}' | grep -w 'portainer/portainer-ce:2.21.2' || true | ||
register: ce_image_exists | ||
changed_when: false | ||
|
||
- name: Remove Portainer CE image | ||
command: docker rmi portainer/portainer-ce:2.21.2 | ||
when: ce_image_exists.stdout != "" | ||
|
||
- name: Check if Portainer BE image exists | ||
shell: docker images --format '{{"{{.Repository}}:{{.Tag}}"}}' | grep -w 'portainer/portainer-ee:2.21.2' || true | ||
register: be_image_exists | ||
changed_when: false | ||
|
||
- name: Remove Portainer BE image | ||
command: docker rmi portainer/portainer-ee:2.21.2 | ||
when: be_image_exists.stdout != "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Install Portainer Community Edition | ||
hosts: portainer_ce | ||
become: yes | ||
|
||
tasks: | ||
- name: Create Docker volume for Portainer data | ||
command: docker volume create portainer_data | ||
|
||
- name: Run Portainer CE container | ||
command: docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.21.2 | ||
|
||
- name: Display Docker containers | ||
command: docker ps | ||
register: result | ||
|
||
- name: Show Docker container output | ||
debug: | ||
var: result.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Install Portainer Business Edition | ||
hosts: portainer_ee | ||
become: yes | ||
|
||
tasks: | ||
- name: Create Docker volume for Portainer data | ||
command: docker volume create portainer_data | ||
|
||
- name: Run Portainer BE container | ||
command: docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ee:2.21.2 | ||
|
||
- name: Display Docker containers | ||
command: docker ps | ||
register: result | ||
|
||
- name: Show Docker container output | ||
debug: | ||
var: result.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[portainer_ce] | ||
; debian ansible_host=10.128.0.47 ansible_user=root | ||
; ubuntu ansible_host=10.128.0.48 ansible_user=root | ||
; rhel ansible_host=10.128.0.45 ansible_user=root | ||
ubuntu ansible_host=206.189.226.65 ansible_user=root | ||
|
||
[portainer_ee] | ||
ubuntu ansible_host=206.189.226.65 ansible_user=root | ||
; debian ansible_host=10.128.0.47 ansible_user=root | ||
; ubuntu ansible_host=10.128.0.48 ansible_user=root | ||
; rhel ansible_host=10.128.0.45 ansible_user=root |