From 3d419366c49427505358816f05fbe161fd0e33fb Mon Sep 17 00:00:00 2001 From: Laur Ivan Date: Fri, 17 Sep 2021 09:28:47 +0200 Subject: [PATCH] Add default password for server. --- defaults/main.yml | 1 + tasks/main.yml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index a134ef6..25e6f82 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,3 +4,4 @@ server_host: none portainer_config: /tmp/config portainer_port: "8000" +portainer_password: "changeme" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 67ab86a..7e3fb9a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,22 @@ --- # tasks file for portainer role +# +# Set up the admin password +# +- name: Make sure htpasswd is installed + apt: + name: apache2-utils + state: present + when: inventory_hostname == server_host and server_host and server_host != "none" + +- name: Create bcrypt password + shell: + cmd: | + htpasswd -nb -B admin "{{ portainer_password }}" | cut -d ":" -f 2 + register: portainer_password_bcrypt + when: inventory_hostname == server_host and server_host and server_host != "none" + # # Install portainer server on the server host # @@ -27,6 +43,7 @@ volumes: - "/var/run/docker.sock:/var/run/docker.sock" - "{{ portainer_config }}:/data" + command: [ "--admin-password", "'{{ portainer_password_bcrypt.stdout }}'"] when: inventory_hostname == server_host and server_host and server_host != "none" #