Skip to content

Commit

Permalink
portainer: Setup initial admin user
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Dec 13, 2024
1 parent 25e67f2 commit a257480
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions roles/portainer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@
- name: Remove existing Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/remove_docker_container.yml"

- name: "Check if config folder exists"
ansible.builtin.stat:
path: "{{ portainer_paths_location }}"
register: portainer_config_stat

- name: Create directories
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/directories/create_directories.yml"

- name: Create Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"

- name: Setup Tasks
ansible.builtin.import_tasks: "subtasks/setup.yml"
when: not portainer_config_stat.stat.exists
20 changes: 20 additions & 0 deletions roles/portainer/tasks/subtasks/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#########################################################################
# Title: Saltbox: Portainer Setup Tasks #
# Author(s): salty #
# URL: https://github.com/saltyorg/Saltbox #
# -- #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Setup | Wait 10 seconds
ansible.builtin.wait_for:
timeout: 10

- name: Setup | Create Saltbox user
ansible.builtin.uri:
url: "http://{{ portainer_name }}:9000/api/users/admin/init"
method: POST
return_content: yes
body_format: json
body: {"Username": "{{ user.name }}", "Password": "{{ user.pass }}"}

0 comments on commit a257480

Please sign in to comment.